%I #61 Jul 12 2024 07:24:49
%S 1,4,4,4,4,12,4,4,4,4,12,4,4,12,4,12,4,12,4,4,12,4,4,4,4,20,12,4,4,12,
%T 12,4,4,4,12,12,4,12,4,12,12,12,4,4,4,12,4,4,4,4,20,12,12,12,4,12,4,4,
%U 12,4,12,12,4,4,4,36,4,4,12,4,12,4,4,12,12,20,4,4,12,4,12,4,12,4,4,36
%N Number of lattice points (x,y) on the circumference of a circle of radius n with center at (0,0).
%C Also number of Gaussian integers x + yi having absolute value n. - _Alonso del Arte_, Feb 11 2012
%H Reinhard Zumkeller, <a href="/A046109/b046109.txt">Table of n, a(n) for n = 0..1000</a>
%H Michael Gilleland, <a href="/selfsimilar.html">Some Self-Similar Integer Sequences</a>
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/CircleLatticePoints.html">Circle Lattice Points</a>
%F a(n) = A000328(n) - A051132(n).
%F a(n) = 8*A046080(n) + 4 for n > 0.
%F a(n) = A004018(n^2).
%F From _Jean-Christophe Hervé_, Dec 01 2013: (Start)
%F a(A084647(k)) = 28.
%F a(A084648(k)) = 36.
%F a(A084649(k)) = 44. (End)
%F a(n) = 4 * Product_{i=1..k} (2*e_i + 1) for n > 0, given that p_i^e_i is the i-th factor of n with p_i = 1 mod 4. - _Orson R. L. Peters_, Jan 31 2017
%F a(n) = [x^(n^2)] theta_3(x)^2, where theta_3() is the Jacobi theta function. - _Ilya Gutkovskiy_, Apr 20 2018
%F From _Hugo Pfoertner_, Sep 21 2023: (Start)
%F a(n) = 8*A063014(n) - 4 for n > 0.
%F a(n) = 4*A256452(n) for n > 0. (End)
%e a(5) = 12 because the circumference of the circle with radius 5 will pass through the twelve points (5, 0), (4, 3), (3, 4), (0, 5), (-3, 4), (-4, 3), (-5, 0), (-4, -3), (-3, -4), (0, -5), (3, -4) and (4, -3). Alternatively, we can say the twelve Gaussian integers 5, 4 + 3i, ... , 4 - 3i all have absolute value of 5.
%p N:= 1000: # to get a(0) to a(N)
%p A:= Array(0..N):
%p A[0]:= 1:
%p for x from 1 to N do
%p A[x]:= A[x]+4;
%p for y from 1 to min(x-1,floor(sqrt(N^2-x^2))) do
%p z:= x^2+y^2;
%p if issqr(z) then
%p t:= sqrt(z);
%p A[t]:= A[t]+8;
%p fi
%p od
%p od:
%p seq(A[i],i=0..N); # _Robert Israel_, May 08 2015
%t Table[Length[Select[Flatten[Table[r + I i, {r, -n, n}, {i, -n, n}]], Abs[#] == n &]], {n, 0, 49}] (* _Alonso del Arte_, Feb 11 2012 *)
%o (Haskell)
%o a046109 n = length [(x,y) | x <- [-n..n], y <- [-n..n], x^2 + y^2 == n^2]
%o -- _Reinhard Zumkeller_, Jan 23 2012
%o (Python)
%o from sympy import factorint
%o def a(n):
%o r = 1
%o for p, e in factorint(n).items():
%o if p%4 == 1: r *= 2*e + 1
%o return 4*r if n > 0 else 0
%o # _Orson R. L. Peters_, Jan 31 2017
%o (PARI) a(n)=if(n==0, return(1)); my(f=factor(n)); 4*prod(i=1,#f~, if(f[i,1]%4==1, 2*f[i,2]+1, 1)) \\ _Charles R Greathouse IV_, Feb 01 2017
%o (PARI) a(n)=if(n==0, return(1)); t=0; for(x=1, n-1, y=n^2-x^2; if(issquare(y), t++)); return(4*t+4) \\ _Arkadiusz Wesolowski_, Nov 14 2017
%Y Cf. A004018, A046080, A046110, A046111, A046112, A063014, A256452.
%Y Cf. A000328, A051132.
%K nonn,easy,nice
%O 0,2
%A _Eric W. Weisstein_