Which is the highest cube n^3 < 10
8 that can be incremented by a single digit from 1 to 9 to yield a perfect square?
For example, 8 is a perfect cube. When incremented by 1 it becomes 81, which is a perfect square.
hv=10^(8/3)
for n=1:hv
cu=n^3;
for d=1:9
sq=cu+d;
sr=round(sqrt(sq));
if sr^2==sq
fprintf('%5d %5d %3d %8d %4d\n',n, cu, d, sq, sr)
end
end
end
finds
hv =
464.158883361278
1 1 3 4 2
1 1 8 9 3
2 8 1 9 3
2 8 8 16 4
3 27 9 36 6
6 216 9 225 15
40 64000 9 64009 253
46 97336 8 97344 312
indicating the program checked n through 464^3 = 99,897,344 and found the above, so the highest is 46^3 = 97,336. When 8 is added it becomes 97,344, which is 312^2.
|
Posted by Charlie
on 2024-01-21 12:39:47 |