1 2 3 4 5 6 7 8 9 10 11 12 13 |
# the son (age S now) is not yet a teenager for S in range(1, 13): # the grandfather (age G now) is over 60 G = 6 * S if G > 60: # in the years it takes the mother (age M now) to reach the # grandfather's current age, the son will become 9 years older # than the mother's current age; hence G - M = (M + 9) - S M, r = divmod(G + S - 9, 2) if not r: print(f'The mother is {M} (the son is {S}, the grandfather is {G}).') |

Let the son’s, the mother’s and the (grand)father’s ages be \(s\), \(m\) and \(g\) respectively and let \(x\) years elapse before the mother reaches her father’s age now. We have two equations:

\begin{align}g=m+x&=6s\\s +x&=m+9\end{align} which allow \(x\) to be eliminated giving:\[2m=7s-9\] Multiplying this by 4 and rewriting it\(\pmod 7\) now gives: \[m = 6\pmod 7\]and hence:\[m=7k+6\] where \(k\) is an integer. We can now substitute this into the earlier equations to show that:\begin{align}s&=2k+3\\ x&=5k+12\\g&=12k+18\end{align}

We know that \(g\) is greater than 60, which means that \(k >= 4\). We also know that \(s\) is less than 13 so \(k < 5\). So \(k=4\), which gives the mother's age now as 34. This makes the son's age 11 and the grandfather's age 66.

]]>