Find a three-digit number containing three different digits where the following are all perfect squares:
(A) The sum of the first digit and the number formed by the second and third digits;
(B) The first digit multiplied by the number formed by the second and third digits and
(C) The sum of the three digits.
This program:
FOR a = 1 TO 9
FOR b = 0 TO 9
FOR c = 0 TO 9
t1 = a + 10 * b + c
st1 = INT(SQR(t1) + .5)
IF st1 * st1 = t1 THEN
t2 = a * (10 * b + c)
st2 = INT(SQR(t2) + .5)
IF st2 * st2 = t2 THEN
t3 = a + b + c
st3 = INT(SQR(t3) + .5)
IF st3 * st3 = t3 THEN
PRINT a; b; c
END IF
END IF
END IF
NEXT
NEXT
NEXT
Produces
1 0 0
2 0 2
4 0 0
8 0 8
9 0 0
9 1 6
so that if "the number formed by the second and third digits" is not allowed to have a leading zero, then 916 is the only solution.
|
Posted by Charlie
on 2003-05-15 11:25:51 |