Finding integer solution to solve a puzzle

294 Views Asked by At

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)

1

There are 1 best solutions below

0
On BEST ANSWER

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$$