I was chatting with an older friend of mine when I happened to mention the ages of my two children. He said to me, "when your youngest was born your age was the square of the older one. Now your age is the product of both their ages."
I then thought about his age and the ages of his children and replied, "When your youngest was born your age was the product of the older two. Later on your age was the product of the oldest and youngest. Now your age is the product of the younger two."
What are our two ages?
(Assume we all have the same birthday.)
DEFDBL AZ
CLS
PRINT "narrator:"
FOR father = 15 TO 70
FOR d1 = 2 TO father  13
FOR d2 = 1 TO d1  1
t1father = father  d2
t1oldest = d1  d2
IF t1father = t1oldest * t1oldest THEN
IF father = d1 * d2 THEN PRINT father, d1, d2
END IF
NEXT
NEXT
NEXT
PRINT : PRINT "friend:"
FOR father = 15 TO 70
FOR d1 = 3 TO father  13
FOR d2 = 2 TO d1  1
FOR d3 = 1 TO d2  1
t1father = father  d3
t1oldest = d1  d3
t1middle = d2  d3
IF t1father = t1oldest * t1middle THEN
good = 0
FOR yago = d3  1 TO 1 STEP 1
t1father = father  yago
t1oldest = d1  yago
t1middle = d2  yago
t1youngest = d3  yago
IF t1father = t1oldest * t1youngest THEN good = 1: EXIT FOR
NEXT yago
IF good THEN IF father = d2 * d3 THEN PRINT father, d1, d2, d3, yago
END IF
NEXT
NEXT
NEXT
NEXT
finds
narrator:
40 10 4
friend:
66 18 11 6 2
so the narrator is 40 and his friend is 66.
The narrator's children are 10 and 4; the friend's children are 18, 11 and 6, and the "later on" in the narrator's description of the friend's situation was 2 years ago, when the friend was 64, the product of 16 and 4.

Posted by Charlie
on 20130122 16:48:29 