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.

A025435 Number of partitions of n into 2 distinct squares.

Original entry on oeis.org

0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 0
Offset: 0

Views

Author

Keywords

Comments

a(A004435(n)) = 0; a(A001983(n)) > 0. - Reinhard Zumkeller, Dec 20 2013

Examples

			G.f. = x + x^4 + x^5 + x^9 + x^10 + x^13 + x^16 + x^17 + x^20 + 2*x^25 + ...
		

Crossrefs

Programs

  • Haskell
    a025435 0 = 0
    a025435 n = a010052 n + sum
       (map (a010052 . (n -)) $ takeWhile (< n `div` 2) $ tail a000290_list)
    -- Reinhard Zumkeller, Dec 20 2013
    
  • Maple
    A025435 := proc(n)
        local i, j, ans;
        ans := 0;
        for i from 0 to n do
            for j from i+1 to n do
                if i^2+j^2=n then
                    ans := ans+1
                fi
            end do
        end do;
        ans ;
    end proc: # R. J. Mathar, Aug 04 2018
  • Mathematica
    a[ n_] := If[ n < 0, 0, Sum[ Boole[ n == i^2 + j^2], {i, Sqrt[n]}, {j, 0, i - 1}]]; (* Michael Somos, Jun 24 2015 *)
    a[ n_] := Length@ PowersRepresentations[ n, 2, 2] - Boole @ IntegerQ @ Sqrt[2 n]; (* Michael Somos, Jun 24 2015 *)
    a[ n_] := SeriesCoefficient[ With[ {f = (EllipticTheta[ 3, 0, x] + 1)/2, g = (EllipticTheta[ 3, 0, x^2] + 1)/2}, f f - g] / 2, {x, 0, n}]; (* Michael Somos, Jun 24 2015 *)
  • PARI
    {a(n) = if( n<0, 0, sum(i=1, sqrtint(n), sum(j=0, i-1, n == i^2 + j^2)))}; /* Michael Somos, Jun 24 2015 */
    
  • PARI
    A025435(n)=sum(k=sqrtint((n-1+!n)\2)+1, sqrtint(n), issquare(n-k^2))-issquare(n/2) \\ or A000161(n)-issquare(n/2). - M. F. Hasler, Aug 05 2018
    
  • Python
    from math import prod
    from sympy import factorint
    def A025435(n):
        f = factorint(n)
        return int(not any(e&1 for p,e in f.items() if p>2))*(1-((f.get(2,0)&1)<<1)) + (((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 0 # Chai Wah Wu, Sep 08 2022

Formula

a(n) = A000161(n) - A010052(2*n). - M. F. Hasler, Aug 05 2018
a(n) = Sum_{i=1..n} c(i) * c(2*n-i), where c is the square characteristic (A010052). - Wesley Ivan Hurt, Nov 26 2020