### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,367)
- misc (4)
- project euler (2)
- puzzle (90)
- puzzle# (48)
- site news (58)
- tantalizer (94)
- teaser (7)

### Site Stats

- 233,130 hits

Programming Enigma Puzzles

4 February 2015

Posted by on **From New Scientist #2414, 27th September 2003** [link]

George’s supposedly secret four-digit PIN code is the product of five different prime numbers. It is also the product of the ages of Fred, George and Herb. George’s age is the average of the other two. Only one of the trio is a teenager.

What is the PIN code?

[enigma1258]

%d bloggers like this:

Programmatically we can examine all 4-digit numbers, look for ones with 5 distinct prime factors, and then assign them to ages to fit the conditions (which is how I wrote my first program). This Python program takes a more efficient approach. It runs in 34ms.

Solution:The PIN is 9570.The ages are 15, 22 and 29. Which have factors of (3, 5), (2, 11) and (29).

Another variation

HI Arthur,

When the five prime factors are split among the three ages, they can split (1,1,3) or (1,2,2). How did you eliminate the (1,1,3) split?

Although I can see why F and H can only have one or two prime factors, I am not sure why G cannot have three prime factors (c.f. the ‘G in candidates’ test and the only one of (F,G,H) is prime test).

Good point, I hadn’t thought of the 1,1,3 split.

Here is a further development of Arthur’s approach that runs on Python 3. It uses my Python number theory library but can be modified relatively easily to use Jim’s enigma.py.

Hi Geoff,

Isn’t your solution making the assumption that the middle number is a composite? As it turns out, the middle number of the solution is composite, but I’m not sure whether that can be assumed in the search.

Hi Arthur, Two can be a factor of only one of the three ages, and if it was a

factor of either the lowest or highest age, the middle age wouldn’t be

an integer. So, yes, the middle age has 2 as a factor, which makes it

composite (it can’t be 2)

Hi Geoff,

I still can’t see why 2 has to be a factor of the middle integer.

I have worked it out now – the smallest 5 primes other than 2 have a five digit product, 3*5*7*11*13=15015

In fact no prime factor can be greater than 47, as 2*3*5*7*48 = 10080

My memory is like a sieve – I had worked this out for my solution below but when you asked the question I couldn’t remember why! I am hence mightily relieved that you found the answer. I must remember to add more comments as I get older!

My, this one is popular! Mine is essentially the same as Jim’s.

If all ages are in the teenage years, there is another potential solution:

% PIN code = 2730, Fred = 15, George = 14, Herb = 13 , 5 factors are (3,5,2,7,13)