Teenager A: I found an interesting relation between my age and the age of my father. Multiplying my age by the age of my father I get the same result if we use the correct ages or if both of us reverse the ages' digits prior to the multiplication.
Same happens if I do it with my grandfather's or even with my aged grand-grand father's ages.
B, A's brother:
That applies to my age as well.
C, a friend: My age, too. But no grand-grandfather...
All the ages (A,B,C) are distinct.
What are they?
CLS
OPEN "allfamil.txt" FOR OUTPUT AS #2
FOR teen = 11 TO 50
revteen = (teen MOD 10) * 10 + (teen \ 10)
FOR father = teen + 12 TO teen + 70
revfath = (father MOD 10) * 10 + (father \ 10)
IF teen * father = revteen * revfath THEN
FOR grand = father + 12 TO father + 70
grands$ = LTRIM$(STR$(grand))
r$ = ""
FOR i = 1 TO LEN(grands$)
r$ = MID$(grands$, i, 1) + r$
NEXT
revgrand = VAL(r$)
IF teen * grand = revteen * revgrand AND grand < 100 THEN
PRINT teen, father, grand
PRINT #2, teen, father, grand
FOR great = grand + 12 TO grand + 77
greats$ = LTRIM$(STR$(great))
r$ = ""
FOR i = 1 TO LEN(greats$)
r$ = MID$(greats$, i, 1) + r$
NEXT
revgreat = VAL(r$)
IF teen * great = revteen * revgreat AND great < 100 THEN
PRINT teen, father, grand, great
PRINT #2, teen, father, grand, great
END IF
NEXT
END IF
NEXT grand
END IF
NEXT father
NEXT teen
This expands the age group considered and limits the highest age to under 100.
In keeping with the spirit of reversing the digits would mean, ages 11, 22, 33 and 44 were deleted from the possibilities:
12 42 63
12 42 63 84
12 42 84
12 63 84
13 31 62
13 31 62 93
13 31 93
13 62 93
14 41 82
21 36 48
23 64 96
24 42 63
24 42 63 84
24 42 84
24 63 84
26 62 93
28 41 82
32 46 69
36 63 84
39 62 93
46 64 96
48 63 84
Only the 12- and 24-year-olds can share a common age, 84, for their great grandfather and so are the brothers, while C can be any of the 13-, 14-, 23-, etc. agers.
|
Posted by Charlie
on 2011-11-21 12:34:33 |