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.

Showing 1-10 of 15 results. Next

A000161 Number of partitions of n into 2 squares.

Original entry on oeis.org

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

Views

Author

Keywords

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.
Let Pk = the number of partitions of n into k nonzero squares. Then we have A000161 = P0 + P1 + P2, A002635 = P0 + P1 + P2 + P3 + P4, A010052 = P1, A025426 = P2, A025427 = P3, A025428 = P4. - Charles R Greathouse IV, Mar 08 2010, amended by M. F. Hasler, Jan 25 2013
a(A022544(n))=0; a(A001481(n))>0; a(A125022(n))=1; a(A118882(n))>1. - Reinhard Zumkeller, Aug 16 2011

Examples

			25 = 3^2+4^2 = 5^2, so a(25) = 2.
		

References

  • J. V. Uspensky and M. A. Heaslet, Elementary Number Theory, McGraw-Hill, NY, 1939, p. 339

Crossrefs

Equivalent sequences for other numbers of squares: A010052 (1), A000164 (3), A002635 (4), A000174 (5).

Programs

  • Haskell
    a000161 n =
       sum $ map (a010052 . (n -)) $ takeWhile (<= n `div` 2) a000290_list
    a000161_list = map a000161 [0..]
    -- Reinhard Zumkeller, Aug 16 2011
    
  • 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) ];
    A000161 := n -> nops( numtheory[sum2sqr](n) ); # M. F. Hasler, Nov 23 2007
  • Mathematica
    Length[PowersRepresentations[ #,2,2]] &/@Range[0,150] (* Ant King, Oct 05 2010 *)
  • PARI
    a(n)=sum(i=0,n,sum(j=0,i,if(i^2+j^2-n,0,1))) \\ for illustrative purpose
    
  • PARI
    A000161(n)=sum(k=sqrtint((n-1)\2)+1,sqrtint(n),issquare(n-k^2)) \\ Charles R Greathouse IV, Mar 21 2014, improves earlier code by M. F. Hasler, Nov 23 2007
    
  • PARI
    A000161(n)=#sum2sqr(n) \\ See A133388 for sum2sqr(). - M. F. Hasler, May 13 2018
    
  • Python
    from math import prod
    from sympy import factorint
    def A000161(n):
        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

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

A000164 Number of partitions of n into 3 squares (allowing part zero).

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1, 0, 1, 2, 2, 1, 1, 1, 1, 0, 1, 2, 2, 2, 0, 2, 1, 0, 1, 2, 2, 1, 2, 1, 2, 0, 1, 3, 1, 1, 1, 2, 1, 0, 1, 2, 3, 2, 1, 2, 3, 0, 1, 2, 1, 2, 0, 2, 2, 0, 1, 3, 3, 1, 2, 2, 1, 0, 2, 2, 3, 2, 1, 2, 1, 0, 1, 4, 2, 2, 1, 2, 3, 0, 1, 4, 3, 1, 0, 1, 2, 0, 1, 2, 3, 3, 2, 4, 2, 0, 2
Offset: 0

Views

Author

Keywords

Comments

a(n) = number of triples of integers [ i, j, k] such that i >= j >= k >= 0 and n = i^2 + j^2 + k^2. - Michael Somos, Jun 05 2012

Examples

			G.f. = 1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^8 + 2*x^9 + x^10 + x^11 + x^12 + x^13 + ...
		

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, NY, 1985, p. 84.

Crossrefs

Equivalent sequences for other numbers of squares: A000161 (2), A002635 (4), A000174 (5).
Cf. A004215 (positions of zeros), A094942 (positions of ones), A124966 (positions of greater values).

Programs

  • Maple
    A000164 := proc(n)
        local a,x,y,z2,z ;
        a := 0 ;
        for x from 0 do
            if 3*x^2 > n then
                return a;
            end if;
            for y from x do
                if x^2+2*y^2 > n then
                    break;
                end if;
                z2 := n-x^2-y^2 ;
                if issqr(z2) then
                    z := sqrt(z2) ;
                    if z >= y then
                        a := a+1 ;
                    end if;
                end if;
            end do:
        end do:
        a;
    end proc: # R. J. Mathar, Feb 12 2017
  • Mathematica
    Length[PowersRepresentations[ #, 3, 2]] & /@ Range[0, 104]
    e[0,r_,s_,m_]=0;e[n_,r_,s_,m_]:=Length[Select[Divisors[n],Mod[ #,m]==r &]]-Length[Select[Divisors[n],Mod[ #,m]==s &]];alpha[n_]:=5delta[n]+3delta[1/2 n]+4delta[1/3n];beta[n_]:=4e[n,1,3,4]+3e[n,1,7,8]+3e[n,3,5,8];delta[n_]:=If[IntegerQ[Sqrt[n]],1,0];f[n_]:=Table[n-k^2, {k,1,Floor[Sqrt[n]]}]; gamma[n_]:=2 Plus@@(e[ #,1,3,4] &/@f[n]);p3[n_]:=1/12(alpha[n]+beta[n]+gamma[n]);p3[ # ] &/@Range[0,104]
    (* Ant King, Oct 15 2010 *)
    a[ n_] := If[ n < 0, 0, Sum[ Boole[ n == i^2 + j^2 + k^2], {i, 0, Sqrt[n]}, {j, 0, i}, {k, 0, j}]]; (* Michael Somos, Aug 15 2015 *)
  • PARI
    {a(n) = if( n<0, 0, sum( i=0, sqrtint(n), sum( j=0, i, sum( k=0, j, n == i^2 + j^2 + k^2))))}; /* Michael Somos, Jun 05 2012 */
    
  • Python
    import collections; a = collections.Counter(i*i + j*j + k*k for i in range(100) for j in range(i+1) for k in range(j+1)) # David Radcliffe, Apr 15 2019

Formula

Let e(n,r,s,m) be the excess of the number of n's r(mod m) divisors over the number of its s (mod m) divisors, and let delta(n)=1 if n is a perfect square and 0 otherwise. Then, if we define alpha(n) = 5*delta(n) + 3*delta(n/2) + 4*delta(n/3), beta(n) = 4*e(n,1,3,4) + 3*e(n,1,7,8) + 3*e(n,3,5,8), gamma(n) = 2*Sum_{1<=k^2Ant King, Oct 15 2010

Extensions

Name clarified by Wolfdieter Lang, Apr 08 2013

A002635 Number of partitions of n into 4 squares.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1, 1, 3, 3, 3, 3, 2, 2, 2, 1, 3, 4, 2, 4, 3, 3, 2, 2, 3, 4, 3, 2, 4, 2, 2, 2, 4, 5, 3, 5, 3, 5, 3, 1, 4, 5, 3, 3, 4, 3, 4, 2, 4, 6, 4, 4, 4, 5, 2, 3, 5, 5, 5, 5, 4, 4, 3, 2, 6, 7, 4, 5, 5, 5, 4, 2, 5, 9, 5, 3, 5, 4, 3, 1, 6, 7, 6, 7, 5, 7, 5, 3, 6, 7, 4
Offset: 0

Views

Author

Keywords

Comments

a(A124978(n)) = n; a(A006431(n)) = 1; a(A180149(n)) = 2; a(A245022(n)) = 3. - Reinhard Zumkeller, Jul 13 2014

Examples

			1: 1000; 2: 1100; 3:1110; 4: 2000 and 1111; 5: 2100; 6: 2110; 7: 2111; 8: 2200; 9: 3000 and 2210; 10: 3100 and 2211; etc.
		

References

  • G. Loria, Sulla scomposizione di un intero nella somma di numeri poligonali. (Italian) Atti Accad. Naz. Lincei. Rend. Cl. Sci. Fis. Mat. Nat. (8) 1, (1946). 7-15.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Equivalent sequences for other numbers of squares: A010052 (1), A000161 (2), A000164 (3), A000174 (5), A000177 (6), A025422 (7), A025423 (8), A025424 (9), A025425 (10).

Programs

  • Haskell
    a002635 = p (tail a000290_list) 4 where
    p ks'@(k:ks) c m = if m == 0 then 1 else
    if c == 0 || m < k then 0 else p ks' (c - 1) (m - k) + p ks c m
    -- Reinhard Zumkeller, Jul 13 2014
  • Mathematica
    Length[PowersRepresentations[ #, 4, 2]] & /@ Range[0, 107] (* Ant King, Oct 19 2010 *)
  • PARI
    for(n=1,100,print1(sum(a=0,n,sum(b=0,a,sum(c=0,b,sum(d=0,c,if(a^2+b^2+c^2+d^2-n,0,1))))),","))
    
  • PARI
    a(n)=local(c=0); if(n>=0, forvec(x=vector(4,k,[0,sqrtint(n)]),c+=norml2(x)==n,1)); c
    

A294524 Numbers that have a unique partition into a sum of five nonnegative squares.

Original entry on oeis.org

0, 1, 2, 3, 6, 7, 15
Offset: 1

Views

Author

Robert Price, Nov 01 2017

Keywords

Comments

This sequence is finite and complete. See the von Eitzen Link and the proof in A294675 stating that for n > 5408, the number of ways to write n as a sum of 5 squares (without allowing zero squares) is at least floor(sqrt(n - 101) / 8) = 9. Since this sequence relaxes the restriction of zero squares the number of representations for n > 5408 is at least nine. Then an inspection of n <= 5408 completes the proof.

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, New York, 1985, p. 86, Theorem 1.

Crossrefs

Programs

  • Mathematica
    m = 5;
    r[n_] := Reduce[xx = Array[x, m]; 0 <= x[1] && LessEqual @@ xx && AllTrue[xx, NonNegative] && n == Total[xx^2], xx, Integers];
    For[n = 0, n < 20, n++, rn = r[n]; If[rn[[0]] === And, Print[n, " ", rn]]] (* Jean-François Alcover, Feb 25 2019 *)

A295150 Numbers that have exactly two representations as a sum of five nonnegative squares.

Original entry on oeis.org

4, 5, 8, 9, 10, 11, 12, 14, 23, 24
Offset: 1

Views

Author

Robert Price, Nov 15 2017

Keywords

Comments

This sequence is finite and complete. See the von Eitzen Link and the proof in A294675 stating that for n > 5408, the number of ways to write n as a sum of 5 squares (without allowing zero squares) is at least floor(sqrt(n - 101) / 8) = 9. Since this sequence relaxes the restriction of zero squares, the number of representations for n > 5408 is at least nine. Then an inspection of n <= 5408 completes the proof.

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, New York, 1985, p. 86, Theorem 1.

Crossrefs

Programs

  • Mathematica
    okQ[n_] := Length[PowersRepresentations[n, 5, 2]] == 2;
    Select[Range[100], okQ] (* Jean-François Alcover, Feb 26 2019 *)

A295159 Smallest number with exactly n representations as a sum of five nonnegative squares.

Original entry on oeis.org

0, 4, 13, 20, 29, 37, 50, 52, 61, 74, 77, 85, 91, 101, 106, 118, 125, 131, 133, 139, 162, 157, 154, 166, 178, 194, 187, 205, 203, 202, 227, 211, 226, 235, 234, 269, 251, 275, 250, 266, 291, 274, 259, 283, 301, 325, 306, 298, 326, 334, 347, 322, 362, 447, 331
Offset: 1

Views

Author

Robert Price, Nov 15 2017

Keywords

Comments

Conjecture: a(448) does not exist, i.e., there is no number with exactly 448 such representations. - Robert Israel, Nov 15 2017

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, New York, 1985, p. 86, Theorem 1.

Crossrefs

Programs

  • Maple
    N:= 1000: # to get a(1)...a(n) where a(n+1) is the first term > N
    V:= Array(0..N):
    for x[1] from 0 to floor(sqrt(N/5)) do
      for x[2] from x[1] while x[1]^2 + 4*x[2]^2 <= N do
        for x[3] from x[2] while x[1]^2 + x[2]^2 + 3*x[3]^2 <= N do
          for x[4] from x[3] while x[1]^2 + x[2]^2 + x[3]^2 + 2*x[4]^2 <= N do
            for x[5] from x[4] while x[1]^2 + x[2]^2 + x[3]^2 + x[4]^2 + x[5]^2 <= N do
               t:=  x[1]^2 + x[2]^2 + x[3]^2 + x[4]^2 + x[5]^2;
               V[t]:= V[t]+1;
    od od od od od:
    A:= Vector(max(V),-1):
    for i from 0 to N do if A[V[i]]=-1 then A[V[i]]:= i fi od:
    T:= select(t -> A[t]=-1, [$1..max(V)]):
    if T = [] then nmax:= max(V) else nmax:= T[1]-1 fi:
    convert(A[1..nmax],list); # Robert Israel, Nov 15 2017

Formula

A000174(a(n))=n. - Robert Israel, Nov 15 2017

A295160 Largest number with exactly n representations as a sum of five nonnegative squares.

Original entry on oeis.org

15, 24, 39, 60, 57, 96, 87, 105, 120, 111, 132, 128, 177, 192, 160, 240, 201, 188, 209, 249, 228, 233, 217, 273, 312, 252, 297, 321, 345, 384, 348, 313, 393, 329, 377, 360, 417, 361, 401, 432, 480, 440, 409, 473, 528, 489, 388, 537, 457, 513, 452, 512, 545
Offset: 1

Views

Author

Robert Price, Nov 15 2017

Keywords

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, New York, 1985, p. 86, Theorem 1.

Crossrefs

A295153 Numbers that have exactly five representations as a sum of five nonnegative squares.

Original entry on oeis.org

29, 34, 35, 36, 38, 40, 41, 42, 44, 46, 55, 57
Offset: 1

Views

Author

Robert Price, Nov 15 2017

Keywords

Comments

This sequence is finite and complete. See the von Eitzen Link and the proof in A294675 stating that for n > 5408, the number of ways to write n as a sum of 5 squares (without allowing zero squares) is at least floor(sqrt(n - 101) / 8) = 9. Since this sequence relaxes the restriction of zero squares, the number of representations for n > 5408 is at least nine. Then an inspection of n <= 5408 completes the proof.

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, New York, 1985, p. 86, Theorem 1.

Crossrefs

A295151 Numbers that have exactly three representations as a sum of five nonnegative squares.

Original entry on oeis.org

13, 16, 17, 18, 19, 21, 22, 30, 31, 33, 39
Offset: 1

Views

Author

Robert Price, Nov 15 2017

Keywords

Comments

This sequence is finite and complete. See the von Eitzen Link and the proof in A294675 stating that for n > 5408, the number of ways to write n as a sum of 5 squares (without allowing zero squares) is at least floor(sqrt(n - 101) / 8) = 9. Since this sequence relaxes the restriction of zero squares, the number of representations for n > 5408 is at least nine. Then an inspection of n <= 5408 completes the proof.

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, New York, 1985, p. 86, Theorem 1.

Crossrefs

A295152 Numbers that have exactly four representations as a sum of five nonnegative squares.

Original entry on oeis.org

20, 25, 26, 27, 28, 32, 47, 48, 60
Offset: 1

Views

Author

Robert Price, Nov 15 2017

Keywords

Comments

This sequence is finite and complete. See the von Eitzen Link and the proof in A294675 stating that for n > 5408, the number of ways to write n as a sum of 5 squares (without allowing zero squares) is at least floor(sqrt(n - 101) / 8) = 9. Since this sequence relaxes the restriction of zero squares, the number of representations for n > 5408 is at least nine. Then an inspection of n <= 5408 completes the proof.

References

  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, New York, 1985, p. 86, Theorem 1.

Crossrefs

Showing 1-10 of 15 results. Next