login
a(n) = number of ways of writing n as the sum of two odd positive squares.
6

%I #22 May 17 2023 10:24:14

%S 0,0,1,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,

%T 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,

%U 0,0,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,2

%N a(n) = number of ways of writing n as the sum of two odd positive squares.

%H Antti Karttunen, <a href="/A290081/b290081.txt">Table of n, a(n) for n = 0..11050</a>

%F a(2n) = A008442(n), a(2n+1) = 0.

%e a(2) = 1 as 2 = 1 + 1.

%e a(10) = 2 as 10 = 1 + 9 = 9 + 1.

%e a(50) = 3 as 50 = 1 + 49 = 49 + 1 = 25 + 25.

%o (Scheme) (define (A290081 n) (cond ((< n 2) 0) ((odd? n) 0) (else (let loop ((k (- (A000196 n) (modulo (+ 1 (A000196 n)) 2))) (s 0)) (if (< k 1) s (loop (- k 2) (+ s (A010052 (- n (* k k))))))))))

%o (PARI) upto(n) = {my(m, v, res = vector(n)); m = (sqrtint(n)+1)\2; v = vector(m, i, (2*i-1)^2); forvec(x = vector(2, i, [1, #v]), s = v[x[1]] + v[x[2]]; if(s <= n, res[s]+=(1+(x[1]!=x[2]))), 1);concat(0, res)} \\ _David A. Corneth_, Jul 24 2017

%o (PARI)

%o A008442(n) = if( n<1 || n%4!=1, 0, sumdiv(n, d, (d%4==1) - (d%4==3))); \\ This function from _Michael Somos_, Apr 24 2004

%o A290081(n) = if(n%2,0,A008442(n/2));

%o (Python)

%o from sympy import divisors

%o def A290081(n): return 0 if n&1 else 0 if (m:=n>>1)&3!=1 else sum(((a:=d&3)==1)-(a==3) for d in divisors(m,generator=True)) # _Chai Wah Wu_, May 17 2023

%Y Cf. A008437, A063725.

%Y Bisections: A000004, A008442.

%K nonn

%O 0,11

%A _Antti Karttunen_, Jul 24 2017