Teaser 2415: [Double shift]
From The Sunday Times, 4th January 2009 [link]
I have written down a large number in which no digit occurs more than twice. If I were to move the last digit of the number from the end to the front of the number, then the effect would be to double the number. If I repeated the process with the new number, then the effect would be to double it again. And if I repeated the process again, the effect would be to double the number yet again.
What is the number that I have written down?
This puzzle was originally published with no title.
[teaser2415]
Jim Randell 10:06 am on 27 January 2026 Permalink |
If we suppose the original number n is of the form:
Then moving the final digit to the front gives us:
From which we derive that a is a k-digit number, such that:
If the number contains no digit more than twice, then the longest the number can be is 20 digits long, and so we can consider k up to 19.
This Python program runs in 70ms. (Internal runtime is 719µs).
from enigma import (irange, div, nsplit, rotate, zip_eq, seq2str, printf) # check a candidate number <n> (with digits <ds>) def check(n, ds): # check no digit occurs more than twice if any(ds.count(x) > 2 for x in set(ds)): return # record shifts that result in doublings ns = [n] # collect doubling sequences while True: n *= 2 ds = rotate(ds, -1) if not zip_eq(ds, nsplit(n)): break ns.append(n) return ns # look for up to 19 digits prefixes for k in irange(1, 19): x = 10**k - 2 # consider possible final digits for z in irange(1, 9): a = div(x * z, 19) if a is None: continue n = 10*a + z ds = nsplit(n) if len(ds) != k + 1: continue ns = check(n, ds) if ns and len(ns) >= 4: printf("{ns}", ns=seq2str(ns, sep=" -> ", enc=""))Solution: The number is: 105263157894736842.
The number is 18 digits long, and uses each digit twice except 0 and 9 (which are used once each).
Shifting the final digit to the front multiple times we get:
A run of 4 is the longest run we can get in base 10 (as n × 16 will not have the same number of digits as n), but there is another run of 3 we can make:
These numbers are the repetends of fractions of the form k / 19.
LikeLike