|
|
A000161
|
|
Number of partitions of n into 2 squares.
|
|
63
|
|
|
1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 2, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 2, 1, 0, 0, 1, 0, 1, 0
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,26
|
|
COMMENTS
|
Number of ways of writing n as a sum of 2 (possibly zero) squares when order does not matter.
Number of similar sublattices of square lattice with index n.
|
|
REFERENCES
|
J. V. Uspensky and M. A. Heaslet, Elementary Number Theory, McGraw-Hill, NY, 1939, p. 339
|
|
LINKS
|
R. T. Bumby, Sums of four squares, in Number theory (New York, 1991-1995), 1-8, Springer, New York, 1996.
J. H. Conway, E. M. Rains and N. J. A. Sloane, On the existence of similar sublattices, Canad. J. Math. 51 (1999), 1300-1306 (Abstract, pdf, ps).
|
|
FORMULA
|
a(n) = card { { a,b } c N | a^2+b^2 = n }. - M. F. Hasler, Nov 23 2007
Let f(n)= the number of divisors of n that are congruent to 1 modulo 4 minus the number of its divisors that are congruent to 3 modulo 4, and define delta(n) to be 1 if n is a perfect square and 0 otherwise. Then a(n)=1/2 (f(n)+delta(n)+delta(1/2 n)). - Ant King, Oct 05 2010
|
|
EXAMPLE
|
25 = 3^2+4^2 = 5^2, so a(25) = 2.
|
|
MAPLE
|
A000161 := proc(n) local i, j, ans; ans := 0; for i from 0 to n do for j from i to n do if i^2+j^2=n then ans := ans+1 fi od od; RETURN(ans); end; [ seq(A000161(i), i=0..50) ];
|
|
MATHEMATICA
|
Length[PowersRepresentations[ #, 2, 2]] &/@Range[0, 150] (* Ant King, Oct 05 2010 *)
|
|
PROG
|
(PARI) a(n)=sum(i=0, n, sum(j=0, i, if(i^2+j^2-n, 0, 1))) \\ for illustrative purpose
(Haskell)
a000161 n =
sum $ map (a010052 . (n -)) $ takeWhile (<= n `div` 2) a000290_list
a000161_list = map a000161 [0..]
(Python)
from math import prod
from sympy import factorint
f = factorint(n)
return int(not any(e&1 for e in f.values())) + (((m:=prod(1 if p==2 else (e+1 if p&3==1 else (e+1)&1) for p, e in f.items()))+((((~n & n-1).bit_length()&1)<<1)-1 if m&1 else 0))>>1) if n else 1 # Chai Wah Wu, Sep 08 2022
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,core,easy,nice
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|