Number shuffle

This is a number theory problem from the Riddler. Simple problem, not-so-simple solution!

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?

Here is my solution:
[Show Solution]

6 thoughts on “Number shuffle”

  1. Hi Laurent, interesting solution and appreciate the explanation of your thought process. I got the same answer but using a mechanical process with significantly less thought going into it. If you assume the last digit of the solution and use that as a “seed”, the answer falls out quickly.

    Assume the last digit of the solution is 4, that means the next-to-last digit is 8 (2×4), the third-to-last digit is 6 (2×8=16, carry the one), fourth-to-last digit is 3 (2×6+1 carried from previously), fifth-to-last digit is 7 (2×3+1), etc. Continue until the first digit repeats the last digit. At that point you will be guaranteed to have a number which taking the last digit and moving to the front is double the original number, i.e., a “solution” but not necessarily the smallest solution (i.e., solution to the 538 puzzle).

    Following this procedure the solution assuming 4 as seed the “solution” is: 210526315789473684

    Follow the same procedure using different last digit seeds to fairly quickly find all of the possible answers, the smallest being the 538 puzzle solution. That is the same as your answer: 105263157894736842

      1. Yes, I didn’t put as much thought into this week’s puzzle as usual. Actually in my solution you only need to arbitrarily choose one value for the last digit. All the other possible solutions fall out directly since the different solutions are just repeating cycles of that one. It’s apparent that the solution choosing 2 is the same as the solution choosing 4, just take the first digit and move it to the end.

        1. Same is true in my solution, actually. First step is to pick $n$ such that $10^n-2$ is a multiple of $19$. This happens precisely when $n=17+18k$ for some $k$. Then, you pick $d_0$ (the last digit), and all solutions must have the form:
          \]so long as the number $\tfrac{10^n-2}{19}$ has $n$ digits.

          The simplest solution is when $k=0$ and $d_0=1$, but can increase $d_0$ to get the rest of the solutions and then increase $k$, etc.

          1. Laurent, I worked out the below list of other minimm values for “m-number shuffles”, i.e., numbers that replicate when multiplying by m and moving the last digit to the front. I used the seeding method to find solutions. Wondering whether your solution also generalizes for different m-multiples and can derive the same results.

            2×105263157894736842 (18 digits)
            3×1034482758620689655172413793 (28 digits)
            4×102564 (6 digits)
            5×102040816326530612244897959183673469387755 (42 digits)
            6×1016949152542372881355932203389830508474576271186440677966 (58 digits)
            7×1014492753623188405797 (22 digits)
            8×1012658227848 (13 digits)
            9×10112359550561797752808988764044943820224719 (44 digits)

  2. Hi Jason,

    Yes, the solution generalizes. For example, if the number has the form $Md_0$ where $M$ has $n$ digits and moving the last digit $d_0$ to the front results in multiplication by $m$, then the equation we must solve is:
    (10m-1)M = (10^n-m)d_0
    \]For example, if we let $m=3$, then we have: $29M=(10^n-3)d_0$. Therefore, $29$ must divide $10^n-3$. The smallest $n$ for which this is true is $n=27$. This is easy to test computationally. Since there are only 28 possible integers modulo 29, you never have to test more than 28 numbers and if you don’t find an answer, there does not exist one. The next step is to look for $M$, which is equal to $M=\frac{10^{27}-3}{29}d_0$. This number must have $n=27$ digits. If we let $d_0=1$ or $d_0=2$, it only has 26 digits. We first achieve 27 digits when we let $d_0=3$, so that’s the answer. The final answer is therefore:
    10M+d_0 = 1034482758620689655172413793
    \]and this is the same solution you found.

Leave a Reply

Your email address will not be published. Required fields are marked *