**From New Scientist #1350, 24th March 1983** [link]

Every Christmas I assemble my three nephews and ask each to state his mental age, which must be an exact whole number of years not greater than 100. Then I give to each, for every year of his stated age, as many pounds as he says he is years old.

Both last year and this year I noticed that my total outlay could be more simply calculated by just multiplying the three ages together.

Last year all three claimed the same age. This year the three ages were all different, and none was the same as last year’s.

Can you tell me last year’s and this year’s trios of ages? The answers, I believe, are unique. Trial and error will be shortened once you notice that if (A, B, C) is a possible trio of ages, so is …

[enigma204]

### Like this:

Like Loading...

This Python program runs in 104ms.

Solution:Last years stated ages were 3, 3, 3; This years stated ages were 6, 15, 87.The problem reduces to finding (p, q, r) such that p² + q² + r² = p×q×r, with numbers from 1 to 100.

There are five triples:

(3, 3, 3)

(3, 3, 6)

(3, 6, 15)

(3, 15, 39)

(6, 15, 87)

The only triple with all the numbers the same is (3, 3, 3), and the only triple that doesn’t include 3 is (6, 15, 87).

Here’s another version that considers fewer combinations. Supposing p < q < r, it considers pairs of values for p and q, and then looks for solutions of the quadratic equation:

p² + q² + r² = pqr

⇒ r² + (-pq)r + (p² + q²) = 0

It runs in 47ms.