1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from fractions import gcd """ Later consecutive ages are a,a+1,..,a+4 Earlier ages, at father's death, are a-1,a+1,..,a+4 sum of earlier ages = 5a+9 sum of later ages = 5a+10 lcm of the sums is their product, (5a+9)(5a+10) difference of youngest son's inheritance at his two ages is a multiple of a(5a+9) - (a-1)(5a+10) = 4a+10 which must be a divisor of 1000 """ for a in xrange(2, 120): diff = 4 * a + 10 if 1000 % diff == 0: print "Youngest son is", a - 1, # scale up by 1000 / diff so that difference in youngest son's inheritence is 1000 tesares tesares = (5 * a + 9) * (5 * a + 10) * 1000 / diff print ", total of {} tesares".format(tesares) |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
from itertools import count from math import gcd def lcm(a, *r): for b in r: a *= b // gcd(a, b) return abs(a) # For all the son's ages at the father's death to be different # but then become consecutive a few hours later, the youngest # son must be two years younger than the next youngest; all # the sons were present in 2000 so they are age 17 or older for a in count(17): # form the two sets of ages t = tuple(range(a + 2, a + 6)) ages, seq_ages = (a,) + t, (a + 1,) + t # for the sons to each receive integer inheritances in both # situations, the Sultan's fortune must be a multiple of the # least common multiple of the sums of these sets of ages sa, ss = sum(ages), sum(seq_ages) f = lcm(sa, ss) # the ratios (inheritance / age) for the two sets of ages ma, ms = f // sa, f // ss # only the youngest son will benefit from the delay and the # amount by which he benefits must be a divisor of 1000 m, r = divmod(1000, (ms * seq_ages[0] - ma * ages[0])) if not r: f, ma, ms = (m * x for x in (f, ma, ms)) ih = tuple(ma * x for x in ages) ihs = tuple(ms * x for x in seq_ages) print(f'{f} tesares [{ih}, {ihs}].') exit() |

The only arrangement of the son’s ages that are all different at the father’s death but which would produce consecutive ages if the father’s death had been delayed by a few hours is as follows: \[(a, a+2, a+3, a+4,a+5)\]The ages at the delayed death are then: \[(a+1, a+2, a+3,a+4,a+5)\]The inheritances are proportional to these ages so we can express the Sultan’s fortune \(f\) as: \[f = m(5 a+14) = n(5 a + 15)\] where \(m\) and \(n\) are the inheritance over age ratios for the two sets of ages. We are also told that the one son who would benefit from a delayed death would gain 1000 tesares, which gives:\[n(a + 1) – m a = 1000\] These two equations allow \(m\) and \(f\) to be determined from \(a\) as:\[m=2500\frac{(a+3)}{(2a+7)}\] \[f=2500\frac{(a + 3)(5a+14)}{(2a+7)}\]Since \(m\) is an integer, we are looking for values of \(2a+7\) that are divisors of 2500. Moreover, we know tht \(a\) is at least 17 and, say, less than 120 so the only divisors of 2500 that we need to consider are 50, 100 and 125. Of these only 125 gives an integer \(a\) value (= 59) and hence a Sultan’s fortune of 383160 tesares.

You can investigate this teaser further using Erling Torkildsen’s nice GeoGebra model here.

]]>