Published in the old blog in 1022/08/16
I recently got recommended a YouTube video by MindYourDecisions with the following problem:
Which number doubles when the last digit becomes the first digit?
What is meant by „becomes the first digit“ is that the last digit is moved to the front and all others shift right one place, a rotation like „12345 -> 51234“ (which does not double 12345 as desired). It turns out that there are more videos with the same or a similar problem. I did not watch one of them. That’s the kind of problem I like to solve on my own. Let me share my thought process.
Everybody will probably try to find the number by using an algebraic equation. It turns out that rotation is surprisingly difficult to represent. A simple form should look like this:
2(10x+d) = 10^nd+x
There are some side conditions, however. The number d must be a single digit from 1 to 10, and x must be a natural number with exactly n digits. The equation above is equivalent to
x = \frac{10^n-2}{19} d
Thus, 19 must dived 10^n-2. Now, if you know a bit about Fermat’s little theorem and Algebra, you notice that 19 is prime and 10^n modulo 19 will run through all numbers 1 to 18. In fact, we get for the remainders of 10^n if divided by 10 the following sequence:
1,10,5,12,6,3,11,15,17,18,9,14,7,13,16,8,4,2,11,10,5, \\12,6,3,11,15,17,18,9,14,7,13,16,8,4,2,1
We find the remainder 2 for 10^17. In fact,
1017−219=52631578947368421017−219=5263157894736842
Now, we have some choices for d. Note, that the number above has only 16 digits, but our n was 17. But already with d=2 we get a 17-digit number. We found the following solution (remember N=10x+d):
N = 2 \cdot 5263157894736842 \cdot 10 + 2 = 105263157894736842
Indeed
2N = 210526315789473684
A mathematician should never be satisfied with a solution that has been found in this fiddling way. The first obvious question is: Are there more solutions?
Indeed, we can set d=2,3,4,5,6,7,8,9 and get 8 different solutions:
105263157894736842,…,473684210526315789
For n=17, there are no more than these. But Fermat’s theorem and our computations above tell us that 10^18=1 modulo 19. Thus, we get more solutions by adding multiples of 18, e.g.:
\frac{10^{35}−2}{19}⋅2⋅10+2 =105263157894736842105263157894736842
At that point, you should get suspicious and try to reflect on previous knowledge, in this case periodic decimal representations. I noticed this only after a while. But then it dawned to me:
\frac{2}{19} = 0.\overline{105263157894736842}
and
\frac{4}{19}=0.210526315789473684
The reason is that 40 divided by 19 yields 2 with a remainder of 2. Then 20 divided by 19 yields 1 with a remainder of 1. Then comes a 0 with a remainder of 10 etc. The process goes through all 18 remainders, before it repeats itself.
Starting at half of 20, i.e. with 10, we get the 1 from the second place of our digits. Thus, we get the sequence rotated to the left. This easily explains our result.
Why doesn’t the process work with 1/7? There, we never meet that d/7 is 2d/7 shifted one place. However,
5⋅142857=714285
This can be explained in the same way using the decimal representation of 1/7.
Try 4/39, 16/39, 7/69, 49/69 for more.
Nice, isn’t it?