# Finding integer solution to solve a puzzle

I have been given the following puzzle:

find the smallest number that it's right most digit is 2, and if you remove that digit and place it on the left most side of the number it will double its value

this is what i have gotten:

• a number we seek (minus last digit)
• b is the a's digit count+1

$$2(10a+2) = 2*10^b+a$$ which yields $$a = \frac{2*10^b-4}{19}$$

I could not solve the above equation, can any one help me in finding integer solutions (analytically that is - not brute force) ?

b.t.w: the puzzle itself i have solved building the number digit by digit, the solution is very interesting as it is related to the above equation though i cannot understand as to why.

Spoiler

it is the number created by the Repeating decimal of 2/19 (18 digits)

• Since you already know the answer to this "question", this should probably be on Puzzling.SE instead. – A.P. Jun 15 '15 at 15:34
• @A.P. i dont know the answer, as i stated in the question i want to know how to solve the above equation analytically. – Mike Jun 15 '15 at 16:13
• But what is your question, then? And what about the spoiler block? – A.P. Jun 15 '15 at 16:36
• You need to make your question more clear or else this post may be closed. – Mike Pierce Jun 16 '15 at 0:14
• @MikePierce sorry, you are right. English is not my native tongue. i have edited question to make it more clear. it took me a few re-reads to understand it is not clear. apologies – Mike Jun 16 '15 at 6:05

Your equation $a=\dfrac{2\cdot10^b-4}{19}$ is correct, hence you are looking for a $b$ such that $$2\cdot10^b\equiv4\mod19.$$

Then (sorry, this is kind of brute force), compute $2\cdot10^b\bmod19$ for increasing $b$, using the following rules:

• $2\cdot10^{b+1}\bmod19=10(2\cdot10^b\bmod19)\bmod19$ (compute by recurrence)
• for even $n=2k$, $10n\bmod19=20k\bmod19=k$ (write the half of $n$)
• for odd $n=2k+1$, $10n\bmod19=20k+10\bmod19=k+10$ (write $1$ followed by the half of $n$)

Then the successive remainders starting from $b=1$ are

$$1,10,5,12,6,3,11,15,17,18,9,14,7,13,16,8,4,2,1\cdots$$

and $b=17$.

The number is $$105263157894736842$$