2 min read

Can You Shuffle Numbers?

Table of Contents

Riddler Classic

Imagine taking a number and moving its last digit to the front. For example, 1,234 would become 4,123. What is the smallest positive integer such that when you do this, the result is exactly double the original number? (For bonus points, solve this one without a computer.)

Solution

Let the last digit of our mystery number be aa, and the rest of it be bb. So the number we’re searching for equals 10b+a10b+a. Let bb be an nn-digit number. Then, moving the last digit to the front gives a new number equal to 10nβ‹…a+b=2(10b+a10n \cdot a + b = 2(10b+a).

Simplifying that gives (10nβˆ’2)a=19b(10^nβˆ’2)a=19b. For aa and bb to be integers, we need the left-hand side to be divisible by 1919, like the right-hand side is. In other words, we need it to be the case that 10n=210^n=2 mod 1919.

From Little Fermat’s Theorem we have

1018≑1mod  19β€…β€ŠβŸΉβ€…β€Š2β‹…1018≑2mod  19β€…β€ŠβŸΉβ€…β€Š20β‹…1017≑2mod  19β€…β€ŠβŸΉβ€…β€Š1017≑2mod  19Β asΒ 20≑1mod  19.\begin{aligned} 10^{18} & \equiv 1 \mod 19 \\ \implies 2 \cdot 10^{18} &\equiv 2 \mod 19 \\ \implies 20 \cdot 10^{17} &\equiv 2 \mod 19 \\ \implies 10^{17} &\equiv 2 \mod 19 \text{ as } 20 \equiv 1 \mod 19. \end{aligned}

Therefore the smallest nn for which 10n=210^n=2 mod 1919 is true is n=17n=17.

So we have [(1017βˆ’2)/19]β‹…a=5,263,157,894,736,842β‹…a=b[(10^{17}βˆ’2)/19] \cdot a = 5,263,157,894,736,842 \cdot a = b.