# mixedmath

Explorations in math and programming
David Lowry-Duda

While idly thinking while heading back from the office, and then more later while thinking after dinner with my academic little brother Alex Walker and my future academic little sister-in-law Sara Schulz, we began to think about $2017$, the number.

## General Patterns

• 2017 is a prime number. 2017 is the 306th prime. The 2017th prime is 17539.
• As 2011 is also prime, we call 2017 a sexy prime.
• 2017 can be written as a sum of two squares, $$2017 = 9^2 +44^2,$$ and this is the only way to write it as a sum of two squares.
• Similarly, 2017 appears as the hypotenuse of a primitive Pythagorean triangle, $$2017^2 = 792^2 + 1855^2,$$ and this is the only such right triangle.
• 2017 is uniquely identified as the first odd prime that leaves a remainder of $2$ when divided by $5$, $13$, and $31$. That is, $$2017 \equiv 2 \pmod {5, 13, 31}.$$
• In different bases, \begin{align} (2017)_{10} &= (2681)_9 = (3741)_8 = (5611)_7 = (13201)_6 \notag \\ &= (31032)_5 = (133201)_4 = (2202201)_3 = (11111100001)_2 \notag \end{align} The base $2$ and base $3$ expressions are sort of nice, including repetition.

## Counting to 20

$$\begin{array}{ll} 1 = 2\cdot 0 + 1^7 & 11 = 2 + 0! + 1 + 7 \\ 2 = 2 + 0 \cdot 1 \cdot 7 & 12 = 20 - 1 - 7 = -2 + (0! + 1)\cdot 7 \\ 3 = (20 + 1)/7 = 20 - 17 & 13 = 20 - 1 \cdot 7 \\ 4 = -2 + 0 - 1 + 7 & 14 = 20 - (-1 + 7) \\ 5 = -2 + 0\cdot 1 + 7 & 15 = -2 + 0 + 17 \\ 6 = -2 + 0 + 1 + 7 & 16 = -(2^0) + 17 \\ 7 = 2^0 - 1 + 7 & 17 = 2\cdot 0 + 17 \\ 8 = 2 + 0 - 1 + 7 & 18 = 2^0 + 17 \\ 9 = 2 + 0\cdot 1 + 7 & 19 = 2\cdot 0! + 17 \\ 10 = 2 + 0 + 1 + 7 & 20 = 2 + 0! + 17. \end{array}$$

In each expression, the digits $2, 0, 1, 7$ appear, in order, with basic mathematical symbols. I wonder what the first number is that can't be nicely expressed (subjectively, of course)?

## Iterative Maps on 2017

Now let's look at less-common manipulations with numbers.

• The digit sum of $2017$ is $10$, which has digit sum $1$.
• Take $2017$ and its reverse, $7102$. The difference between these two numbers is $5085$. Repeating gives $720$. Continuing, we get $$2017 \mapsto 5085 \mapsto 720 \mapsto 693 \mapsto 297 \mapsto 495 \mapsto 99 \mapsto 0.$$ So it takes seven iterations to hit $0$, where the iteration stabilizes.
• Take $2017$ and its reverse, $7102$. Add them. We get $9119$, a palindromic number. Continuing, we get \begin{align} 2017 &\mapsto 9119 \mapsto 18238 \mapsto 101519 \notag \\ &\mapsto 1016620 \mapsto 1282721 \mapsto 2555542 \mapsto 5011094 \mapsto 9912199. \notag \end{align} It takes one map to get to the first palindrome, and then seven more maps to get to the next palindrome. Another five maps would yield the next palindrome.
• Rearrange the digits of $2017$ into decreasing order, $7210$, and subtract the digits in increasing order, $0127$. This gives $7083$. Repeating once gives $8352$. Repeating again gives $6174$, at which point the iteration stabilizes. This is called Kaprekar's Constant.
• Consider Collatz: If $n$ is even, replace $n$ by $n/2$. Otherwise, replace $n$ by $3\cdot n + 1$. On $2017$, this gives \begin{align} 2017 &\mapsto 6052 \mapsto 3026 \mapsto 1513 \mapsto 4540 \mapsto \notag \\ &\mapsto 2270 \mapsto 1135 \mapsto 3406 \mapsto 1703 \mapsto 5110 \mapsto \notag \\ &\mapsto 2555 \mapsto 7666 \mapsto 3833 \mapsto 11500 \mapsto 5750 \mapsto \notag \\ &\mapsto 2875 \mapsto 8626 \mapsto 4313 \mapsto 12940 \mapsto 6470 \mapsto \notag \\ &\mapsto 3235 \mapsto 9706 \mapsto 4853 \mapsto 14560 \mapsto 7280 \mapsto \notag \\ &\mapsto 3640 \mapsto 1820 \mapsto 910 \mapsto 455 \mapsto 1366 \mapsto \notag \\ &\mapsto 683 \mapsto 2050 \mapsto 1025 \mapsto 3076 \mapsto 1538 \mapsto \notag \\ &\mapsto 769 \mapsto 2308 \mapsto 1154 \mapsto 577 \mapsto 1732 \mapsto \notag \\ &\mapsto 866 \mapsto 433 \mapsto 1300 \mapsto 650 \mapsto 325 \mapsto \notag \\ &\mapsto 976 \mapsto 488 \mapsto 244 \mapsto 122 \mapsto 61 \mapsto \notag \\ &\mapsto 184 \mapsto 92 \mapsto 46 \mapsto 23 \mapsto 70 \mapsto \notag \\ &\mapsto 35 \mapsto 106 \mapsto 53 \mapsto 160 \mapsto 80 \mapsto \notag \\ &\mapsto 40 \mapsto 20 \mapsto 10 \mapsto 5 \mapsto 16 \mapsto \notag \\ &\mapsto 8 \mapsto 4 \mapsto 2 \mapsto 1 \notag \end{align} It takes $69$ steps to reach the seemingly inevitable $1$. This is much shorter than the $113$ steps necessary for $2016$ or the $113$ (yes, same number) steps necessary for $2018$.
• Consider the digits $2,1,7$ (in that order). To generate the next number, take the units digit of the product of the previous $3$. This yields $$2,1,7,4,8,4,8,6,2,6,2,4,8,4,\ldots$$ This immediately jumps into a periodic pattern of length $8$, but $217$ is not part of the period. So this is preperiodic.
• Consider the digits $2,0,1,7$. To generate the next number, take the units digit of the sum of the previous $4$. This yields $$2,0,1,7,0,8,6,1,5,0,2,8,\ldots, 2,0,1,7.$$ After 1560 steps, this produces $2,0,1,7$ again, yielding a cycle. Interestingly, the loop starting with $2018$ and $2019$ also repeat after $1560$ steps.
• Take the digits $2,0,1,7$, square them, and add the result. This gives $2^2 + 0^2 + 1^2 + 7^2 = 54$. Repeating, this gives \begin{align} 2017 &\mapsto 54 \mapsto 41 \mapsto 17 \mapsto 50 \mapsto 25 \mapsto 29 \notag \\ &\mapsto 85 \mapsto 89 \mapsto 145 \mapsto 42 \mapsto 20 \mapsto 4 \notag \\ &\mapsto 16 \mapsto 37 \mapsto 58 \mapsto 89\notag\end{align} and then it reaches a cycle.
• Take the digits $2,0,1,7$, cube them, and add the result. This gives $352$. Repeating, we get $160$, and then $217$, and then $352$. This is a very tight loop.

## A Few Matrices

• One can make $2017$ from determinants of basic matrices in a few ways. For instance, \begin{align} \left \lvert \begin{pmatrix} 1&2&3 \\ 4&6&7 \\ 5&8&9 \end{pmatrix}\right \rvert &= 2, \qquad \left \lvert \begin{pmatrix} 1&2&3 \\ 4&5&6 \\ 7&8&9 \end{pmatrix}\right \rvert &= 0\notag \\ \left \lvert \begin{pmatrix} 1&2&3 \\ 4&7&6 \\ 5&9&8 \end{pmatrix}\right \rvert &= 1 , \qquad \left \lvert \begin{pmatrix} 1&2&3 \\ 4&5&7 \\ 6&8&9 \end{pmatrix}\right \rvert &= 7\notag \end{align} The matrix with determinant $0$ has the numbers $1$ through $9$ in the most obvious configuration. The other matrices are very close in configuration.
• Alternately, \begin{align} \left \lvert \begin{pmatrix} 1&2&3 \\ 5&6&9 \\ 4&8&7 \end{pmatrix}\right \rvert &= 20 \notag \\ \left \lvert \begin{pmatrix} 1&2&3 \\ 6&8&9 \\ 5&7&4 \end{pmatrix}\right \rvert &= 17 \notag \end{align} So one can form $20$ and $27$ separately from determinants.
• One cannot make $2017$ from a determinant using the digits $1$ through $9$ (without repetition).
• If one uses the digits from the first $9$ primes, it is interesting that one can choose configurations with determinants equal to $2016$ or $2018$, but there is no such configuration with determinant equal to $2017$.

Info on how to comment

bold, italics, and plain text are allowed in comments. A reasonable subset of markdown is supported, including lists, links, and fenced code blocks. In addition, math can be formatted using $(inline math)$ or $$(your display equation)$$.