A063725 Number of ordered pairs (x,y) of positive integers such that x^2 + y^2 = n.
0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 2, 0, 0, 2, 0, 0, 0, 2, 1, 0, 2, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 0, 1, 0, 2, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 4, 0, 0, 2, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 4, 0, 0, 0, 2, 2, 0, 0
Offset: 0
Keywords
Examples
a(5) = 2 from the solutions (1,2) and (2,1).
Links
Crossrefs
Programs
-
Haskell
a063725 n = sum $ map (a010052 . (n -)) $ takeWhile (< n) $ tail a000290_list a063725_list = map a063725 [0..] -- Reinhard Zumkeller, Aug 16 2011
-
Mathematica
nn = 100; t = Table[0, {nn}]; s = Sqrt[nn]; Do[n = x^2 + y^2; If[n <= nn, t[[n]]++], {x, s}, {y, s}]; Join[{0}, t] (* T. D. Noe, Apr 03 2011 *)
-
PARI
a(n)=if(n==0, return(0)); my(f=factor(n)); prod(i=1, #f~, if(f[i, 1]%4==1, f[i, 2]+1, f[i, 2]%2==0 || f[i, 1]==2)) - issquare(n) \\ Charles R Greathouse IV, May 18 2016
-
Python
from math import prod from sympy import factorint def A063725(n): f = factorint(n) return prod(1 if p==2 else (e+1 if p&3==1 else (e+1)&1) for p, e in f.items())-(not any(e&1 for e in f.values())) if n else 0 # Chai Wah Wu, May 17 2023
Formula
G.f.: (Sum_{m=1..inf} x^(m^2))^2.
G.f.: (theta_3(q) - 1)^2/4, where theta_3() is the Jacobi theta function. - Ilya Gutkovskiy, Aug 08 2018
Comments