# Shifting a digit from right to left

A positive integer n (without leading zeros) has the property that shifting the rightmost digit of n to the left end doubles the number.
Examples: 1->1, 1234->4123, 2020->202

What is the smallest n with this property?

• Very nice question. – hexomino Aug 18 '20 at 17:01
• This is a way cooler question than I first thought it was :) – Greg Martin Aug 19 '20 at 4:55
• This has been discussed in a youtube video: youtube.com/watch?v=1lHDCAIsyb8 – Nilay Ghosh Aug 19 '20 at 7:41
• Wow I did not expect such complexity from such a simple question! Well done. – Dmitry Kamenetsky Aug 19 '20 at 9:54
• @NilayGhosh actually I prefer the answer given in the video. Very nice and easy to understand. – Dmitry Kamenetsky Aug 19 '20 at 9:58

$$N = 20 \left(\frac{10^{17} -2}{19}\right) + 2$$

Proof

Suppose we write our original number as $$N = a_n 10^n + a_{n-1}10^{n-1} +\ldots + a_0 = \displaystyle \sum_{j=0}^n a_j 10^j$$ Then the equation described in the problem is $$2 \displaystyle \sum_{j=0}^n a_j 10^j = a_0 10^n + \displaystyle \sum_{j=1}^n a_j 10^{j-1}$$ Rearranging gives $$\displaystyle \sum_{j=1}^n a_j ((2 \times 10^j) - 10^{j-1}) = a_0 (10^n - 2)$$ which means that $$19 \displaystyle \sum_{j=1}^n a_j 10^{j-1} = a_0 (10^n -2)$$ Now notice that the left hand side is divisible by $$19$$ so the right hand side must be also but since $$a_0$$ is coprime to $$19$$, this means that $$10^n - 2$$ is divisible by $$19$$. Therefore, we are looking for the smallest power of $$10$$ which is congruent to $$2$$ modulo $$19$$.

Going through powers of $$10$$ modulo $$19$$ gives $$10, 5, 12, 6, 3, 11, 15, 17, 18, 9, 14, 7, 13, 16, 8, 4, 2, \ldots$$.
Hence, the smallest power of $$10$$ that works is $$10^{17}$$. Plugging this into our equation gives $$\displaystyle \sum_{j=1}^{17} a_j 10^{j-1} = a_0 \frac{10^{17} -2}{19}$$ Clearly, we cannot pick $$a_0=1$$ as the right-hand side will have too few digits, but if we pick $$a_0=2$$ (to achieve the minimum) then it looks safe that we will have a $$17$$-digit number on the right-hand side and we can just pick the rest of the $$a_j$$ appropriately on the left.

This means that the smallest $$N$$ which works must be $$N = 20 \left(\frac{10^{17} -2}{19}\right) + 2$$

Computer check

Working it out with a computer it seems the value for $$N$$ above is $$105263157894736842$$ and doubling this gives $$210526315789473684$$ so this does indeed work.

• This is a beautiful proof, I love it. – Sciborg Aug 18 '20 at 17:17
• 'rot13("Lbh zvffrq n punapr gb nccyl yvggyr Srezng urer. (10k2 = 1 zbq 19, urapr 10^(19-2) = 2 zbq 19).")' Apart from that, nicely done! – Paul Panzer Aug 18 '20 at 18:00
• Hats off @hexomino. Incredible – DrD Aug 18 '20 at 18:02
• @Paul :rot13(V guvax vg vf erdhverq gb tb guebhtu nyy gur cbjref bs 10 zbq 19 nf qbar ol urkbzvab. Yvggyr Srezng cebivqrf n fbyhgvba, ohg abg arprffnevyl gur fznyyrfg (cevzvgvir ebbg). Sbe rknzcyr: jvgu 10^13 = 10 zbq 13 (yvggyr Srezng) jr trg 10^(13-2) = 4 zbq 13, ohg jr nyfb unir 10^5 = 4 zbq 13) – ThomasL Aug 18 '20 at 19:08
• @ThomasL rot13("Tvir lbh gung. Fgvyy, fubjvat gung 2 vf cevzvgvir vf nf cnvayrff nf Cuv_18(2) = 64 - 8 + 1 = 0 zbq 19 (Cuv_18(K)=K^6-K^3+K vf 18gu plpybgbzvp cbyl). V\'q fnl gung unaqvyl orngf tbvat guebhtu cbjref bs 10 zbq 19.") – Paul Panzer Aug 18 '20 at 20:21