Sunday Times Teaser 3252 – Family Tree
by Danny Roth
Published Sunday January 19 2025 (link)
George and Martha have five daughters; they are, in order of arrival, Andrea, Bertha, Caroline, Dorothy and Elizabeth. They now have ages that are all prime numbers in the range 28 to 60. The average is also a prime number, different from the other five.
Each daughter has a son, Adam, Brian, Colin, David and Edward respectively. They are all mathematics students, and are studying how to calculate square roots without using a calculator. One of them was given a perfect square with three or four digits (none repeated) and told to work out the square root. This he did accurately, getting his mother’s age, but he noted that the sum of the digits of that perfect square was also prime.
Which boy was it, and what is his mother’s age?
-
John Z permalink12345678910111213141516171819202122from itertools import combinationssons = "Adam Brian Colin David Edward".split(' ')# possible ages of mothers, oldest firstp = tuple(i for i in range(59, 28, -2) if all(i % d for d in(3, 5, 7)))# 3 <= sum of three or four digits <= 36: generate primes < 36p36 = tuple(i for i in range(7, 36, 2) if all(i % d for d in(3, 5))) + (3, 5)for p5 in combinations(p, 5):if sum(p5) / 5 in set(p).difference(p5): #avg is prime and not a mother's age# consider mother's agefor n, m in enumerate(p5):if len(str(mm := m * m)) == len(set(str(mm))): #duplicate digits checkif sum(int(d) for d in str(mm)) in p36: #sum digits prime?print(f"{sons[n]}, Mother's age: {m}")