### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,158)
- misc (2)
- project euler (2)
- puzzle (40)
- site news (44)
- tantalizer (42)
- teaser (3)

### Site Stats

- 178,002 hits

Advertisements

Programming Enigma Puzzles

7 November 2016

Posted by on **From New Scientist #2298, 7th July 2001** [link]

Harry used to work for Smallprint, Wriggle, and Payless, a large insurance company. He recalls that every policy number (including some with leading “0”s) had the same number of digits, which was fewer than 20.

He also recalls being passed a neat list of the numbers of five policies for review, and being astonished to find that each number below the first on the list had exactly twice the value of the one above it, and could be obtained from the number above it merely by moving the last digit of that number to its front.

What was the bottom number on his list of five numbers?

[enigma1142]

Advertisements

%d bloggers like this:

I assumed the policy numbers are all different, otherwise the policy with a value of 0 could just be repeated five times to form the list.

The following Python program generates a sequence of numbers where each is

Ntimes the previous number, and this process is repeatedKtimes. For this puzzle we useN = 2, K = 4. It runs in 44ms.Solution:The last number on the list was 842105263157894736.The policy numbers are all 18 digits long. The five policy numbers are:

Additional solutions occur for longer policy numbers that are repeats of the numbers above. So, the next smallest solution occurs with policy numbers that are 36 digits long:

Considered as the digits after a decimal point these numbers correspond to the recurring portion of the fractions 1/19, 2/19, 4/19, 8/19, 16/19.

I started off with some algebraic analysis with the intention of writing some code to solve the problem, but ended up solving the problem completely with algebra:

If the policies have N digits, suppose is one of the first four policies, where y is a single digit, then

so

and ,

So mod .

If , then , i.e. the multiplicative order of 10 mod 19

(http://oeis.org/A084680)

The fifth policy is therefore