clc, clearvars
intCt=0;
r=sqrt(sym(441000));
for x0=0:floor(r)
x=sym(x0);
y=sqrt(r*r-x*x);
if y==round(y)
disp([x round(y)])
else
intCt=intCt+floor(y);
end
end
disp(intCt*4+1)
finds points
[210, 630]
[378, 546]
[546, 378]
[630, 210]
that the circle passes through
That's just the first quadrant, so there are 16 lattice points exactly on the circumference of the circle.
While it was at it, not asked for in the puzzle, the program counted 1,378,381 lattice points strictly within the circle. Well actually it counted 344,595 points on the positive y axis and strictly in the first quadrant not on any axis or circumference, which I multiplied by 4 and added 1 for the origin.
|
Posted by Charlie
on 2021-09-22 11:06:03 |