OFFSET
0,2
COMMENTS
Touching a unit square does not count as covering. E.g., the disk with radius 5 does not cover the unit square with (3, 4) as bottom-left corner.
LINKS
Robert Israel, Table of n, a(n) for n = 0..2000
FORMULA
a(n) = Sum_{k=0..n-1} 4*ceiling(sqrt(n^2-k^2)). - Luis Mendo, Aug 09 2021
EXAMPLE
a(4) = 4 * 15 = 60 because in the positive quadrant 15 unit squares are covered and the problem is symmetrical. In the bounding box of the circle only the unit squares in the corners are not (partially) covered, so a(4) = 8*8 - 4 = 60.
MAPLE
N:= 100: # for a(0)..a(N)
V:=Array(0..N):
for i from 0 to N do
for j from 0 to i do
r:= sqrt(i^2 + j^2);
if r::integer then r:= r+1 else r:= ceil(r) fi;
if r > N then break fi;
if i=j then m:= 4 else m:= 8 fi;
V[r..N]:= V[r..N] +~ m;
od od:
convert(V, list); # Robert Israel, Feb 21 2025
MATHEMATICA
A281795[n_] := 4*Sum[Ceiling[Sqrt[n^2 - k^2]], {k, 0, n-1}];
Array[A281795, 100, 0] (* Paolo Xausa, Feb 21 2025 *)
PROG
(Python)
a = lambda n: sum(4 for x in range(n) for y in range(n)
if x*x + y*y < n*n)
(Octave)
a = @(n) 4*sum(ceil(sqrt(n.^2-(0:n-1).^2))); % Luis Mendo, Aug 09 2021
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Orson R. L. Peters, Jan 30 2017
STATUS
approved