cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

Original entry on oeis.org

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, 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, 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
Offset: 0

Views

Author

Antti Karttunen, Jul 24 2017

Keywords

Examples

			a(2) = 1 as 2 = 1 + 1.
a(10) = 2 as 10 = 1 + 9 = 9 + 1.
a(50) = 3 as 50 = 1 + 49 = 49 + 1 = 25 + 25.
		

Crossrefs

Bisections: A000004, A008442.

Programs

  • 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
    
  • PARI
    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
    A290081(n) = if(n%2,0,A008442(n/2));
    
  • Python
    from sympy import divisors
    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
  • 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))))))))))
    

Formula

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