The following program raises possible ages of the mother to the fourth power. It then divides the resulting number into two parts, and adds the two parts. If the result is a perfect square and its square root is less than the assumed mother's age, the results are printed.
DEFDBL A-Z
CLS
FOR mother = 20 TO 120
m4 = mother * mother * mother * mother
m$ = LTRIM$(STR$(m4))
FOR i = 1 TO LEN(m$) - 1
a = VAL(LEFT$(m$, i)): b = VAL(MID$(m$, i + 1))
fsq = a + b
f = INT(SQR(fsq) + .5)
IF f * f = fsq THEN
IF f < mother AND f > 19 THEN
PRINT f; mother, LEFT$(m$, i); " "; MID$(m$, i + 1)
END IF
END IF
NEXT i
NEXT mother
The results follow:
F M a b
25 50 625 0000
36 60 1296 0000
56 67 2015 1121
49 70 2401 0000
64 80 4096 0000
81 90 6561 0000
where a and b are the numbers the father asked to be added.
However, in all but one instance the father would have had to specify that four zeros be used to enter the zero, which is outside the bounds of what's expected.
So the father is 56, the mother is 67 and the father asked the son to add 2015 and 1121.
|
Posted by Charlie
on 2008-08-04 16:33:44 |