Sunday Times Teaser 3251 – Number Test
by Howard Williams
Published Sunday January 12 2025 (link)
I asked my daughter to find as many three-digit numbers as she could, each of which had the property that the number equalled the sum of the cubes of its individual digits. If she only found one such number, I asked her to give me this number — otherwise, if she had found more than one, to give me the sum of all such numbers found.
She gave me a prime number, from which I could see that not all answers had been found.
Which number or numbers did she not find?
2 Comments
Leave one →
-
John Z. permalink12345678910111213141516from itertools import product, combinationsfrom number_theory import is_primed3 = set()for a, b, c in product(range(1, 10), range(10), range(10)):abc = a * 100 + b * 10 + cif (a ** 3 + b ** 3 + c ** 3) == abc:d3 |= {abc}print("All numbers:", *sorted(d3))for i in range(2, len(d3)):for s in combinations(d3, i):if is_prime(ss := sum(s)):print("Daughter's number", ss, "; Numbers not found:", *d3 - set(s))