What are the two smallest positive whole numbers the difference of whose squares is a cube and the difference of whose cubes is a square ?
(In reply to
Nontrivial Implied by Richard)
The program in two versions: Quick Basic and UBASIC:
DEFDBL AZ
sum = 3
DO
FOR a = 1 TO (sum + 1) / 2  1
b = sum  a
diffSq = b * b  a * a
diffCu = b * b * b  a * a * a
cuRt = INT(diffSq ^ (1 / 3) + .5)
sqRt = INT(SQR(diffCu) + .5)
IF sqRt * sqRt = diffCu AND cuRt * cuRt * cuRt = diffSq THEN
PRINT a, b
ct = ct + 1: IF ct > 40 THEN END
END IF
NEXT
sum = sum + 1
LOOP
10 for Sum=3 to 30000000
15 Max=int((Sum+1)/21)
20 for A=1 to Max
30 B=SumA
40 DiffSq=B*BA*A
50 DiffCu=B*B*BA*A*A
60 CuRt=int(DiffSq^(1/3)+0.5)
70 SqRt=int(sqrt(DiffCu)+0.5)
80 if SqRt*SqRt=DiffCu and CuRt*CuRt*CuRt=DiffSq then
90 :print A,B
100 next
110 next

UBASIC has additional precision available. It was stopped when sum was in the 5000+ range, and found only the two answers I posted. At these high numbers the cubing would get to the murky boundaries of the precision available to QuickBasic.

Posted by Charlie
on 20031206 13:52:06 