Sunday Times Teaser 2793 – Sum Triangles
by Victor Bryant
Published: 3 April 2016 (link)
The number of upwardly-pointing triangles (of all sizes) visible in this picture is ten. Trix has drawn a similar arrangement but with lots more rows: the number of small upward-pointing triangles in her bottom row is equal to her age and the total of upward-pointing triangles that can be seen is divisible by any of the digits 1 to 9.
How old is Trix?
One Comment
Leave one →
-
Brian Gladman permalink12345678910111213141516from itertools import counttriangles = 0# Trix's agefor age in count(1):# the sequence of visible triangles with row# number is 1, 4, 10, 20, 35, ... which are# known as tetrahedral numberstriangles += age * (age + 1) // 2# if this is divisible by 5, 7, 8 and 9 it will# be divisible by all the digits from 1 to 9if not triangles % (5 * 7 * 8 * 9):print('Trix is {} ({} triangles).'.format(age, triangles))break