Written by Colin+ in number theory.

My cunning plan, back last August, was sadly foiled: @christianp refused to rise to the bait.

I'd written a post about finding the smallest number such that moving its final digit to the front of the number doubles its value. It turned out, to my surprise, to be 17 digits long.

Christian, citing work commitments, declined to start a search for numbers that trebled, quadrupled, and so forth.

The post gave two general approaches: the ungainly, but reasonable, approach of starting with a 1 at the end and writing down the appropriate multiples until just before you reached a 1 at the beginning; alternatively, a bit of algebra and Fermat's Little Theorem found the number directly.

I prefer the algebraic method -- but, as we'll see, it hits some problems when it comes to Christian's problem.

Let's start with trebling. We need a number $N$ such that $N = 10a + b$ and $3N = 10^kb + a$, with $k = \lfloor \log{a} \rfloor$.

Ignoring the $k$ restriction for the moment, that gives $30a + 3b = 10^k b + a$, or $29a = \br{10^k - 3}b$. That means, $10^k \equiv 3 \pmod{29}$.

That's (for me, at least) trickier to find than it was for the doubling case. I can work backwards, though: $3\times 10 \equiv 1 \pmod{29}$, and we know from Fermat that $10^{28} \equiv 1 \pmod{29}$ - so $10^{27} \equiv 3 \pmod {29}$.

That means we can find the number we need as $\frac{a}{b} = \frac{10^{27} - 3}{29}$, which works out to be $\frac{a}{b} = 034,482,758,620,689,655,172,413,793$. We can't be doing with a 0 at the beginning, so we can simply let $b=3$ to give us $a=103,448,275,862,068,965,517,241,379$ and $N = 1,034,482,758,620,689,655,172,413,793$. (Not at all coincidentally, that's very similar to the repeating digits of $\frac{3}{29}$.)

What's $\frac{4}{39}$? The Mathematical Ninja would tell you that $\frac{4}{13} = 0.\dot{3}0769\dot{2}$, so $\frac{4}{39} = 0.\dot{1}0256\dot{4}$. That points to 102,564 as a candidate for quadrupling - and it does indeed work!

How about $\frac{5}{49}$? That's $0.102040...$ and goes on for 48 digits, pointing to something in the region of $10^{48}$. However, we know that's not the best answer! 142,857, as @panlepan pointed out in his original tweet, works just fine. (I *think* this is something to do with 49 not being prime.)

On the other hand, 59 is (as are 79 and 89), and the repeating parts of those fractions $\br{\frac{6}{59}, \frac{8}{79}, \frac{9}{89}}$ all lead you to enormous numbers with the property that multiplying them by 6, 8 and 9 respectively - I believe those are the smallest such numbers.

How about 7? 69 is not prime, but $\frac{7}{69}$ does point to a 23-digit number that becomes seven times as large when you move the last digit to the front.

Can you do any better than any of these?

* Thanks to @panlepan for the original puzzle, and to @christianp for suggesting the refinement (and generally being a good egg).

* Edited 2019-09-09 to fix formatting - thanks, @shahlock!

## Michael Pershan

I love this problem, and your doubling post is wonderful as well! I teach at a math camp during the summer (@BEAMMathHQ) and I feel that there was a very similar problem I saw there this past summer. I’ll have to recheck — it might have been about quadrupling.

I am not fluent enough in the number theory to breeze through this post, but I love the problem. I’ll be revisiting this post as I tinker with the problem and remind myself of Fermat’s Little Theorem. Thank you for the post!

## Colin

Thanks, Michael! Glad you enjoyed it.