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 104 results. Next

A344470 Record values in A002654.

Original entry on oeis.org

1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 20, 24, 32, 36, 40, 48, 64, 72, 80, 96, 128, 144, 160, 192, 216, 256, 288, 320, 384, 432, 512, 576, 640, 768, 864, 960, 1024, 1152, 1280, 1536, 1728, 1920, 2048, 2304, 2560, 2880, 3072, 3456, 3840, 4096, 4608, 5120, 5760, 6144
Offset: 1

Views

Author

Jianing Song, May 20 2021

Keywords

Comments

Also numbers k such that A018782(m) > A018782(k) for all m > k.

Examples

			9 is a term because the circle with radius sqrt(4225) centered at the origin hits exactly 4*9 = 36 integer points, and any circle with radius < sqrt(4225) centered at the origin hits fewer than 36 points.
		

Crossrefs

Records of Sum_{d|n} kronecker(m, d): A344472 (m=-3), this sequence (m=-4), A279542 (m=-6).

Programs

  • PARI
    my(v=list(10^15), rec=0); for(n=1, #v, if(numdiv(v[n])>rec, rec=numdiv(v[n]); print1(rec, ", "))) \\ see program for A054994

Formula

a(n) = A071385(n+1)/4.
a(n) = A000005(A071383(n+1)) = A002654(A071383(n+1)).

A120630 Dirichlet inverse of A002654.

Original entry on oeis.org

1, -1, 0, 0, -2, 0, 0, 0, -1, 2, 0, 0, -2, 0, 0, 0, -2, 1, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, -2, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, -2, 0, 0, 0, 2, 0, 0, 0, -1, -1, 0, 0, -2, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, -2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 4, 0, 0, 0, -2, -2, 0, 0, 0, 0, 0, 0, -2, 1, 0, 0, -2, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, -2, 0, 0, 0, 2, 0, 0
Offset: 1

Views

Author

Gerard P. Michon, Jun 25 2006

Keywords

Examples

			a(65)=4 because 65 is 5 times 13 and both of those primes are congruent to 1 modulo 4. Doubling an odd index yields the opposite of the value (e.g., a(130)=-4) because a(2)=-1. Doubling an even index yields zero.
		

Crossrefs

Programs

  • Maple
    A120630 := proc(n)
        local a,pp;
        if n = 1 then
            1;
        else
            a := 1 ;
            for pp in ifactors(n)[2] do
                if op(2,pp) > 2 then
                    a := 0;
                elif op(1,pp) = 2 then
                    if op(2,pp) = 1 then
                        a := -a ;
                    else
                        a := 0 ;
                    end if;
                elif modp(op(1,pp),4) = 3 then
                    if op(2,pp) = 1 then
                        a := 0 ;
                    else
                        a := -a ;
                    end if;
                else
                    if op(2,pp) = 1 then
                        a := -2*a ;
                    else
                        ;
                    end if;
                end if;
            end do:
            a;
        end if;
    end proc: # R. J. Mathar, Sep 15 2015
  • Mathematica
    A120630[n_] := Module[{a, pp}, If[n == 1, 1, a = 1; Do[Which[pp[[2]] > 2, a = 0, pp[[1]] == 2, If[pp[[2]] == 1, a = -a, a = 0], Mod[pp[[1]], 4] == 3, If[pp[[2]] == 1, a = 0, a = -a], True, If[pp[[2]] == 1, a = -2*a]], {pp, FactorInteger[n]}]; a]]; Array[A120630, 120] (* Jean-François Alcover, Apr 24 2017, after R. J. Mathar *)
  • PARI
    seq(n)={dirdiv(vector(n, n, n==1), vector(n, n, sumdiv( n, d, (d%4==1) - (d%4==3))))} \\ Andrew Howroyd, Aug 05 2018

Formula

Multiplicative function with a(p^e)=0 if e>2. a(2)=-1, a(4)=0. If p is a prime congruent to 3 modulo 4, then a(p)=0 and a(p^2)=-1. If p is a prime congruent to 1 modulo 4, then a(p)=-2 and a(p^2)=1.
Sum_{k=1..n} abs(a(k)) ~ c * n, where c = 3/(2*Pi*G) = 0.521269..., and G is Catalan's constant (A006752). - Amiram Eldar, Jan 22 2024

A262209 Inverse Möbius transform of A002654.

Original entry on oeis.org

1, 2, 1, 3, 3, 2, 1, 4, 2, 6, 1, 3, 3, 2, 3, 5, 3, 4, 1, 9, 1, 2, 1, 4, 6, 6, 2, 3, 3, 6, 1, 6, 1, 6, 3, 6, 3, 2, 3, 12, 3, 2, 1, 3, 6, 2, 1, 5, 2, 12, 3, 9, 3, 4, 3, 4, 1, 6, 1, 9, 3, 2, 2, 7, 9, 2, 1, 9, 1, 6, 1, 8, 3, 6, 6, 3, 1, 6, 1, 15, 3, 6, 1, 3, 9
Offset: 1

Views

Author

R. J. Mathar, Sep 15 2015

Keywords

Crossrefs

Programs

  • Mathematica
    f[2, e_] := e + 1; f[p_, e_] := If[Mod[p, 4] == 1, (e + 1)*(e + 2)/2, Floor[e/2] + 1]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* Amiram Eldar, Feb 01 2025 *)
  • PARI
    a(n) = {my(f = factor(n)); prod(i = 1, #f~, if(f[i, 1] == 2, f[i, 2] + 1, if(f[i, 1] % 4 == 1, (f[i, 2]+1)*(f[i, 2]+2)/2, f[i, 2]\2 + 1)));} \\ Amiram Eldar, Feb 01 2025

Formula

G.f.: Sum_{k>=1} tau(k)*x^k/(1 + x^(2*k)), where tau = A000005. - Ilya Gutkovskiy, Sep 14 2019
From Amiram Eldar, Feb 01 2025: (Start)
a(n) = Sum_{d|n} A002654(d).
Multiplicative with a(p^e) = e+1 if p = 2, a(p^e) = floor(e/2) + 1 if p == 3 (mod 4) (A002145), and a(p^e) = (e+1)*(e+2)/2 if p == 1 (mod 4) (A002144). (End)

A213408 Sequence A002654 with the zero terms omitted.

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Jun 10 2012

Keywords

References

  • J. W. L. Glaisher, On the function which denotes the difference between the number of (4m+1)-divisors and the number of (4m+3)-divisors of a number, Proc. London Math. Soc., 15 (1884), 104-122. See Table on page 106.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).

Crossrefs

Cf. A002654.

A001481 Numbers that are the sum of 2 squares.

Original entry on oeis.org

0, 1, 2, 4, 5, 8, 9, 10, 13, 16, 17, 18, 20, 25, 26, 29, 32, 34, 36, 37, 40, 41, 45, 49, 50, 52, 53, 58, 61, 64, 65, 68, 72, 73, 74, 80, 81, 82, 85, 89, 90, 97, 98, 100, 101, 104, 106, 109, 113, 116, 117, 121, 122, 125, 128, 130, 136, 137, 144, 145, 146, 148, 149, 153, 157, 160
Offset: 1

Views

Author

Keywords

Comments

Numbers n such that n = x^2 + y^2 has a solution in nonnegative integers x, y.
Closed under multiplication. - David W. Wilson, Dec 20 2004
Also, numbers whose cubes are the sum of 2 squares. - Artur Jasinski, Nov 21 2006 (Cf. A125110.)
Terms are the squares of smallest radii of circles covering (on a square grid) a number of points equal to the terms of A057961. - Philippe Lallouet (philip.lallouet(AT)wanadoo.fr), Apr 16 2007. [Comment corrected by T. D. Noe, Mar 28 2008]
Numbers with more 4k+1 divisors than 4k+3 divisors. If a(n) is a member of this sequence, then so too is any power of a(n). - Ant King, Oct 05 2010
A000161(a(n)) > 0; A070176(a(n)) = 0. - Reinhard Zumkeller, Feb 04 2012, Aug 16 2011
Numbers that are the norms of Gaussian integers. This sequence has unique factorization; the primitive elements are A055025. - Franklin T. Adams-Watters, Nov 25 2011
These are numbers n such that all of n's odd prime factors congruent to 3 modulo 4 occur to an even exponent (Fermat's two-squares theorem). - Jean-Christophe Hervé, May 01 2013
Let's say that an integer n divides a lattice if there exists a sublattice of index n. Example: 2, 4, 5 divide the square lattice. The present sequence without 0 is the sequence of divisors of the square lattice. Say that n is a "prime divisor" if the index-n sublattice is not contained in any other sublattice except the original lattice itself. Then A055025 (norms of Gaussian primes) gives the "prime divisors" of the square lattice. - Jean-Christophe Hervé, May 01 2013
For any i,j > 0 a(i)*a(j) is a member of this sequence, since (a^2 + b^2)*(c^2 + d^2) = (a*c + b*d)^2 + (a*d - b*c)^2. - Boris Putievskiy, May 05 2013
The sequence is closed under multiplication. Primitive elements are in A055025. The sequence can be split into 3 multiplicatively closed subsequences: {0}, A004431 and A125853. - Jean-Christophe Hervé, Nov 17 2013
Generalizing Jasinski's comment, same as numbers whose odd powers are the sum of 2 squares, by Fermat's two-squares theorem. - Jonathan Sondow, Jan 24 2014
By the 4 squares theorem, every nonnegative integer can be expressed as the sum of two elements of this sequence. - Franklin T. Adams-Watters, Mar 28 2015
There are never more than 3 consecutive terms. Runs of 3 terms start at 0, 8, 16, 72, ... (A082982). - Ivan Neretin, Nov 09 2015
Conjecture: barring the 0+2, 0+4, 0+8, 0+16, ... sequence, the sum of 2 distinct terms in this sequence is never a power of 2. - J. Lowell, Jan 14 2022
All the areas of squares whose vertices have integer coordinates. - Neeme Vaino, Jun 14 2023
Numbers represented by the definite binary quadratic forms x^2 + 2nxy + (n^2+1)y^2 for any integer n. This sequence contains the even powers of any integer. An odd power of a number appears only if the number itself belongs to the sequence. The equation given in the comment by Boris Putievskiy 2013 is Brahmagupta's identity with n = 1. It proves that any set of numbers of the form a^2 + nb^2 is closed under multiplication. - Klaus Purath, Sep 06 2023

References

  • J. H. Conway and N. J. A. Sloane, "Sphere Packings, Lattices and Groups", Springer-Verlag, p. 106.
  • David A. Cox, "Primes of the Form x^2 + n y^2", Wiley, 1989.
  • L. Euler, (E388) Vollständige Anleitung zur Algebra, Zweiter Theil, reprinted in: Opera Omnia. Teubner, Leipzig, 1911, Series (1), Vol. 1, p. 417.
  • S. R. Finch, Mathematical Constants, Cambridge, 2003, pp. 98-104.
  • G. H. Hardy, Ramanujan, pp. 60-63.
  • P. Moree and J. Cazaran, On a claim of Ramanujan in his first letter to Hardy, Expos. Math. 17 (1999), pp. 289-312.
  • 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

Disjoint union of A000290 and A000415.
Complement of A022544.
A000404 gives another version. Subsequence of A091072, supersequence of A046711.
Column k=2 of A336820.

Programs

  • Haskell
    a001481 n = a001481_list !! (n-1)
    a001481_list = [x | x <- [0..], a000161 x > 0]
    -- Reinhard Zumkeller, Feb 14 2012, Aug 16 2011
    
  • Magma
    [n: n in [0..160] | NormEquation(1, n) eq true]; // Arkadiusz Wesolowski, May 11 2016
    
  • Maple
    readlib(issqr): for n from 0 to 160 do for k from 0 to floor(sqrt(n)) do if issqr(n-k^2) then printf(`%d,`,n); break fi: od: od:
  • Mathematica
    upTo = 160; With[{max = Ceiling[Sqrt[upTo]]}, Select[Union[Total /@ (Tuples[Range[0, max], {2}]^2)], # <= upTo &]]  (* Harvey P. Dale, Apr 22 2011 *)
    Select[Range[0, 160], SquaresR[2, #] != 0 &] (* Jean-François Alcover, Jan 04 2013 *)
  • PARI
    isA001481(n)=local(x,r);x=0;r=0;while(x<=sqrt(n) && r==0,if(issquare(n-x^2),r=1);x++);r \\ Michael B. Porter, Oct 31 2009
    
  • PARI
    is(n)=my(f=factor(n));for(i=1,#f[,1],if(f[i,2]%2 && f[i,1]%4==3, return(0))); 1 \\ Charles R Greathouse IV, Aug 24 2012
    
  • PARI
    B=bnfinit('z^2+1,1);
    is(n)=#bnfisintnorm(B,n) \\ Ralf Stephan, Oct 18 2013, edited by M. F. Hasler, Nov 21 2017
    
  • PARI
    list(lim)=my(v=List(),t); for(m=0,sqrtint(lim\=1), t=m^2; for(n=0, min(sqrtint(lim-t),m), listput(v,t+n^2))); Set(v) \\ Charles R Greathouse IV, Jan 05 2016
    
  • PARI
    is_A001481(n)=!for(i=2-bittest(n,0),#n=factor(n)~, bittest(n[1,i],1)&&bittest(n[2,i],0)&&return) \\ M. F. Hasler, Nov 20 2017
    
  • Python
    from itertools import count, islice
    from sympy import factorint
    def A001481_gen(): # generator of terms
        return filter(lambda n:(lambda m:all(d & 3 != 3 or m[d] & 1 == 0 for d in m))(factorint(n)),count(0))
    A001481_list = list(islice(A001481_gen(),30)) # Chai Wah Wu, Jun 27 2022

Formula

n = square * 2^{0 or 1} * {product of distinct primes == 1 (mod 4)}.
The number of integers less than N that are sums of two squares is asymptotic to constant*N/sqrt(log(N)), hence lim_{n->infinity} a(n)/n = infinity.
Nonzero terms in expansion of Dirichlet series Product_p (1 - (Kronecker(m, p) + 1)*p^(-s) + Kronecker(m, p)*p^(-2s))^(-1) for m = -1.
a(n) ~ k*n*sqrt(log n), where k = 1.3085... = 1/A064533. - Charles R Greathouse IV, Apr 16 2012
There are B(x) = x/sqrt(log x) * (K + B2/log x + O(1/log^2 x)) terms of this sequence up to x, where K = A064533 and B2 = A227158. - Charles R Greathouse IV, Nov 18 2022

Extensions

Deleted an incorrect comment. - N. J. A. Sloane, Oct 03 2023

A004018 Theta series of square lattice (or number of ways of writing n as a sum of 2 squares). Often denoted by r(n) or r_2(n).

Original entry on oeis.org

1, 4, 4, 0, 4, 8, 0, 0, 4, 4, 8, 0, 0, 8, 0, 0, 4, 8, 4, 0, 8, 0, 0, 0, 0, 12, 8, 0, 0, 8, 0, 0, 4, 0, 8, 0, 4, 8, 0, 0, 8, 8, 0, 0, 0, 8, 0, 0, 0, 4, 12, 0, 8, 8, 0, 0, 0, 0, 8, 0, 0, 8, 0, 0, 4, 16, 0, 0, 8, 0, 0, 0, 4, 8, 8, 0, 0, 0, 0, 0, 8, 4, 8, 0, 0, 16, 0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 8, 4, 0, 12, 8
Offset: 0

Views

Author

Keywords

Comments

Number of points in square lattice on the circle of radius sqrt(n). Equivalently, number of Gaussian integers of norm n (cf. Conway-Sloane, p. 106).
Let b(n)=A004403(n), then Sum_{k=1..n} a(k)*b(n-k) = 1. - John W. Layman
Theta series of D_2 lattice.
Number 6 of the 74 eta-quotients listed in Table I of Martin (1996).
Ramanujan theta functions: f(q) (see A121373), phi(q) (A000122), psi(q) (A010054), chi(q) (A000700).
The zeros in this sequence correspond to those integers with an equal number of 4k+1 and 4k+3 divisors, or equivalently to those that have at least one 4k+3 prime factor with an odd exponent (A022544). - Ant King, Mar 12 2013
If A(q) = 1 + 4*q + 4*q^2 + 4*q^4 + 8*q^5 + ... denotes the o.g.f. of this sequence then the function F(q) := 1/4*(A(q^2) - A(q^4)) = ( Sum_{n >= 0} q^(2*n+1)^2 )^2 is the o.g.f. for counting the ways a positive integer n can be written as the sum of two positive odd squares. - Peter Bala, Dec 13 2013
Expansion coefficients of (2/Pi)*K, with the real quarter period K of elliptic functions, as series of the Jacobi nome q, due to (2/Pi)*K = theta_3(0,q)^2. See, e.g., Whittaker-Watson, p. 486. - Wolfdieter Lang, Jul 15 2016
Sum_{k=0..n} a(n) = A057655(n). Robert G. Wilson v, Dec 22 2016
Limit_{n->oo} (a(n)/n - Pi*log(n)) = A062089: Sierpinski's constant. - Robert G. Wilson v, Dec 22 2016
The mean value of a(n) is Pi, see A057655 for more details. - M. F. Hasler, Mar 20 2017

Examples

			G.f. = 1 + 4*q + 4*q^2 + 4*q^4 + 8*q^5 + 4*q^8 + 4*q^9 + 8*q^10 + 8*q^13 + 4*q^16 + 8*q^17 + 4*q^18 + 8*q^20 + 12*q^25 + 8*q^26 + ... . - _John Cannon_, Dec 30 2006
		

References

  • L. Comtet, Advanced Combinatorics, Reidel, 1974, p. 162, #16 (7), r(n).
  • J. H. Conway and N. J. A. Sloane, "Sphere Packings, Lattices and Groups", Springer-Verlag, p. 106.
  • N. J. Fine, Basic Hypergeometric Series and Applications, Amer. Math. Soc., 1988; p. 78, Eq. (32.23).
  • E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, NY, 1985, p. 15, p. 32, Lemma 2 (with the proof), p. 116, (9.10) first formula.
  • G. H. Hardy, Ramanujan: twelve lectures on subjects suggested by his life and work, Cambridge, University Press, 1940, p. 133.
  • G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954, p. 240, r(n).
  • W. König and J. Sprekels, Karl Weierstraß (1815-1897), Springer Spektrum, Wiesbaden, 2016, p. 186-187 and p. 280-281.
  • C. D. Olds, A. Lax and G. P. Davidoff, The Geometry of Numbers, Math. Assoc. Amer., 2000, p. 51.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, pages 244-245.
  • E. T. Whittaker and G. N. Watson, A Course of Modern Analysis, fourth edition, reprinted, 1958, Cambridge at the University Press.

Crossrefs

Row d=2 of A122141 and of A319574, 2nd column of A286815.
Partial sums - 1 give A014198.
A071385 gives records; A071383 gives where records occur.

Programs

  • Julia
    # JacobiTheta3 is defined in A000122.
    A004018List(len) = JacobiTheta3(len, 2)
    A004018List(102) |> println # Peter Luschny, Mar 12 2018
    
  • Magma
    Basis( ModularForms( Gamma1(4), 1), 100) [1]; /* Michael Somos, Jun 10 2014 */
    
  • Maple
    (sum(x^(m^2),m=-10..10))^2;
    # Alternative:
    A004018list := proc(len) series(JacobiTheta3(0, x)^2, x, len+1);
    seq(coeff(%, x, j), j=0..len-1) end:
    t1 := A004018list(102);
    r2 := n -> t1[n+1]; # Peter Luschny, Oct 02 2018
  • Mathematica
    SquaresR[2,Range[0,110]] (* Harvey P. Dale, Oct 10 2011 *)
    a[ n_] := SquaresR[ 2, n]; (* Michael Somos, Nov 15 2011 *)
    a[ n_] := SeriesCoefficient[ EllipticTheta[ 3, 0, q]^2, {q, 0, n}]; (* Michael Somos, Nov 15 2011 *)
    a[ n_] := With[{m = InverseEllipticNomeQ @ q}, SeriesCoefficient[ EllipticK[ m] / (Pi/2), {q, 0, n}]]; (* Michael Somos, Jun 10 2014 *)
    a[ n_] := If[ n < 1, Boole[n == 0], 4 Sum[ KroneckerSymbol[-4, d], {d, Divisors@n}]]; (* or *) a[ n_] := SeriesCoefficient[ QPochhammer[ q^2]^10/(QPochhammer[ q] QPochhammer[ q^4])^4, {q, 0, n}]; (* Michael Somos, May 17 2015 *)
  • PARI
    {a(n) = polcoeff( 1 + 4 * sum( k=1, n, x^k / (1 + x^(2*k)), x * O(x^n)), n)}; /* Michael Somos, Mar 14 2003 */
    
  • PARI
    {a(n) = if( n<1, n==0, 4 * sumdiv( n, d, (d%4==1) - (d%4==3)))}; /* Michael Somos, Jul 19 2004 */
    
  • PARI
    {a(n) = if( n<1, n==0, 2 * qfrep([ 1, 0; 0, 1], n)[n])}; /* Michael Somos, May 13 2005 */
    
  • PARI
    a(n)=if(n==0,return(1)); my(f=factor(n)); 4*prod(i=1,#f~, if(f[i,1]%4==1, f[i,2]+1, if(f[i,2]%2 && f[i,1]>2, 0, 1))) \\ Charles R Greathouse IV, Sep 02 2015
    
  • Python
    from sympy import factorint
    def a(n):
        if n == 0: return 1
        an = 4
        for pi, ei in factorint(n).items():
           if pi%4 == 1: an *= ei+1
           elif pi%4 == 3 and ei%2: return 0
        return an
    print([a(n) for n in range(102)]) # Michael S. Branicky, Sep 24 2021
    
  • Python
    from math import prod
    from sympy import factorint
    def A004018(n): return prod(1 if p==2 else (e+1 if p&3==1 else (e+1)&1) for p, e in factorint(n).items())<<2 if n else 1 # Chai Wah Wu, Jul 07 2022, corrected Jun 21 2024.
  • Sage
    Q = DiagonalQuadraticForm(ZZ, [1]*2)
    Q.representation_number_list(102) # Peter Luschny, Jun 20 2014
    

Formula

Expansion of theta_3(q)^2 = (Sum_{n=-oo..+oo} q^(n^2))^2 = Product_{m>=1} (1-q^(2*m))^2 * (1+q^(2*m-1))^4; convolution square of A000122.
Factor n as n = p1^a1 * p2^a2 * ... * q1^b1 * q2^b2 * ... * 2^c, where the p's are primes == 1 (mod 4) and the q's are primes == 3 (mod 4). Then a(n) = 0 if any b is odd, otherwise a(n) = 4*(1 + a1)*(1 + a2)*...
G.f. = s(2)^10/(s(1)^4*s(4)^4), where s(k) := subs(q=q^k, eta(q)) and eta(q) is Dedekind's function, cf. A010815. [Fine]
a(n) = 4*A002654(n), n > 0.
Expansion of eta(q^2)^10 / (eta(q) * eta(q^4))^4 in powers of q. - Michael Somos, Jul 19 2004
Expansion of ( phi(q)^2 + phi(-q)^2 ) / 2 in powers of q^2 where phi() is a Ramanujan theta function.
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = (u - v)^2 - (v - w) * 4 * w. - Michael Somos, Jul 19 2004
Euler transform of period 4 sequence [4, -6, 4, -2, ...]. - Michael Somos, Jul 19 2004
Moebius transform is period 4 sequence [4, 0, -4, 0, ...]. - Michael Somos, Sep 17 2007
G.f. is a period 1 Fourier series which satisfies f(-1 / (4 t)) = 2 (t/i) f(t) where q = exp(2 Pi i t).
The constant sqrt(Pi)/Gamma(3/4)^2 produces the first 324 terms of the sequence when expanded in base exp(Pi), 450 digits of the constant are necessary. - Simon Plouffe, Mar 03 2011
a(n) = A004531(4*n). a(n) = 2*A105673(n), if n>0.
Let s = 16*q*(E1*E4^2/E2^3)^8 where Ek = Product_{n>=1} (1-q^(k*n)) (s=k^2 where k is elliptic k), then the g.f. is hypergeom([+1/2, +1/2], [+1], s) (expansion of 2/Pi*ellipticK(k) in powers of q). - Joerg Arndt, Aug 15 2011
Dirichlet g.f. Sum_{n>=1} a(n)/n^s = 4*zeta(s)*L_(-4)(s), where L is the D.g.f. of the (shifted) A056594. [Raman. J. 7 (2003) 95-127]. - R. J. Mathar, Jul 02 2012
a(n) = floor(1/(n+1)) + 4*floor(cos(Pi*sqrt(n))^2) - 4*floor(cos(Pi*sqrt(n/2))^2) + 8*Sum_{i=1..floor(n/2)} floor(cos(Pi*sqrt(i))^2)*floor(cos(Pi*sqrt(n-i))^2). - Wesley Ivan Hurt, Jan 09 2013
From Wolfdieter Lang, Aug 01 2016: (Start)
A Jacobi identity: theta_3(0, q)^2 = 1 + 4*Sum_{r>=0} (-1)^r*q^(2*r+1)/(1 - q^(2*r+1)). See, e.g., the Grosswald reference (p. 15, p. 116, but p. 32, Lemma 2 with the proof, has the typo r >= 1 instead of r >= 0 in the sum, also in the proof). See the link with the Jacobi-Legendre letter.
Identity used by Weierstraß (see the König-Sprekels book, p. 187, eq. (5.12) and p. 281, with references, but there F(x) from (5.11) on p. 186 should start with nu =1 not 0): theta_3(0, q)^2 = 1 + 4*Sum_{n>=1} q^n/(1 + q^(2*n)). Proof: similar to the one of the preceding Jacobi identity. (End)
a(n) = (4/n)*Sum_{k=1..n} A186690(k)*a(n-k), a(0) = 1. - Seiichi Manyama, May 27 2017
G.f.: Theta_3(q)^2 = hypergeometric([1/2, 1/2],[1],lambda(q)), with lambda(q) = Sum_{j>=1} A115977(j)*q^j. See the Kontsevich and Zagier link, with Theta -> Theta_3, z -> 2*z and q -> q^2. - Wolfdieter Lang, May 27 2018

A056594 Period 4: repeat [1,0,-1,0]; expansion of 1/(1 + x^2).

Original entry on oeis.org

1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0
Offset: 0

Views

Author

Wolfdieter Lang, Aug 04 2000

Keywords

Comments

G.f. is inverse of cyclotomic(4,x). Unsigned: A000035(n+1).
Real part of i^n and imaginary part of i^(n+1), i=sqrt(-1). - Reinhard Zumkeller, Jul 22 2007
The BINOMIAL transform generates A009116(n); the inverse BINOMIAL transform generates (-1)^n*A009116(n). - R. J. Mathar, Apr 07 2008
a(n-1), n >= 1, is the nontrivial Dirichlet character modulo 4, called Chi_2(4;n) (the trivial one is Chi_1(4;n) given by periodic(1,0) = A000035(n)). See the Apostol reference, p. 139, the k = 4, phi(k) = 2 table. - Wolfdieter Lang, Jun 21 2011
a(n-1), n >= 1, is the character of the Dirichlet beta function. - Daniel Forgues, Sep 15 2012
a(n-1), n >= 1, is also the (strongly) multiplicative function h(n) of Theorem 5.12, p. 150, of the Niven-Zuckerman reference. See the formula section. This function h(n) can be employed to count the integer solutions to n = x^2 + y^2. See A002654 for a comment with the formula. - Wolfdieter Lang, Apr 19 2013
This sequence is duplicated in A101455 but with offset 1. - Gary Detlefs, Oct 04 2013
For n >= 2 this gives the determinant of the bipartite graph with 2*n nodes and the adjacency matrix A(n) with elements A(n;1,2) = 1 = A(n;n,n-1), and for 1 < i < n A(n;i,i+1) = 1 = A(n;i,i-1), otherwise 0. - Wolfdieter Lang, Jun 25 2023

Examples

			With a(n-1) = h(n) of Niven-Zuckerman: a(62) = h(63) = h(3^2*7^1) = (-1)^(2*1)*(-1)^(1*3) = -1 = h(3)^2*h(7) = a(2)^2*a(6) = (-1)^2*(-1) = -1. - _Wolfdieter Lang_, Apr 19 2013
		

References

  • T. M. Apostol, Introduction to Analytic Number Theory, Springer-Verlag, 1986.
  • I. S. Gradstein and I. M. Ryshik, Tables of series, products, and integrals, Volume 1, Verlag Harri Deutsch, 1981.
  • Ivan Niven and Herbert S. Zuckerman, An Introduction to the Theory of Numbers, New York: John Wiley (1980), p. 150.
  • Jerome Spanier and Keith B. Oldham, "Atlas of Functions", Hemisphere Publishing Corp., 1987, chapter 32, equation 32:6:1 at page 300.

Crossrefs

Cf. A049310, A074661, A131852, A002654, A146559 (binomial transform).

Programs

  • Magma
    &cat[ [1, 0, -1, 0]: n in [0..23] ]; // Bruno Berselli, Feb 08 2011
    
  • Maple
    A056594 := n->(1-irem(n,2))*(-1)^iquo(n,2); # Peter Luschny, Jul 27 2011
  • Mathematica
    CoefficientList[Series[1/(1 + x^2), {x, 0, 50}], x]
    a[n_]:= KroneckerSymbol[-4,n+1];Table[a[n],{n,0,93}] (* Thanks to Jean-François Alcover. - Wolfdieter Lang, May 31 2013 *)
    CoefficientList[Series[1/Cyclotomic[4, x], {x, 0, 100}], x] (* Vincenzo Librandi, Apr 03 2014 *)
  • Maxima
    A056594(n) := block(
            [1,0,-1,0][1+mod(n,4)]
    )$ /* R. J. Mathar, Mar 19 2012 */
    
  • PARI
    {a(n) = real( I^n )}
    
  • PARI
    {a(n) = kronecker(-4, n+1) }
    
  • Python
    def A056594(n): return (1,0,-1,0)[n&3] # Chai Wah Wu, Sep 23 2023

Formula

G.f.: 1/(1+x^2).
E.g.f.: cos(x).
a(n) = (1/2)*((-i)^n + i^n), where i = sqrt(-1). - Mitch Harris, Apr 19 2005
a(n) = (1/2)*((-1)^(n+floor(n/2)) + (-1)^floor(n/2)).
Recurrence: a(n)=a(n-4), a(0)=1, a(1)=0, a(2)=-1, a(3)=0.
a(n) = T(n, 0) = A053120(n, 0); T(n, x) Chebyshev polynomials of the first kind. - Wolfdieter Lang, Aug 21 2009
a(n) = S(n, 0) = A049310(n, 0); S(n, x) := U(n, x/2), Chebyshev polynomials of 2nd kind.
Sum_{k>=0} a(k)/(k+1) = Pi/4. - Jaume Oliver Lafont, Mar 30 2010
a(n) = Sum_{k=0..n} A101950(n,k)*(-1)^k. - Philippe Deléham, Feb 10 2012
a(n) = (1/2)*(1 + (-1)^n)*(-1)^(n/2). - Bruno Berselli, Mar 13 2012
a(0) = 1, a(n-1) = 0 if n is even, a(n-1) = Product_{j=1..m} (-1)^(e_j*(p_j-1)/2) if the odd n-1 = p_1^(e_1)*p_2^(e_2)*...*p_m^(e_m) with distinct odd primes p_j, j=1..m. See the function h(n) of Theorem 5.12 of the Niven-Zuckerman reference. - Wolfdieter Lang, Apr 19 2013
a(n) = (-4/(n+1)), n >= 0, where (k/n) is the Kronecker symbol. See the Eric Weisstein and Wikipedia links. Thanks to Wesley Ivan Hurt. - Wolfdieter Lang, May 31 2013
a(n) = R(n,0)/2 with the row polynomials R of A127672. This follows from the product of the zeros of R, and the formula Product_{k=0..n-1} 2*cos((2*k+1)*Pi/(2*n)) = (1 + (-1)^n)*(-1)^(n/2), n >= 1 (see the Gradstein and Ryshik reference, p. 63, 1.396 4., with x = sqrt(-1)). - Wolfdieter Lang, Oct 21 2013
a(n) = Sum_{k=0..n} i^(k*(k+1)), where i=sqrt(-1). - Bruno Berselli, Mar 11 2015
Dirichlet g.f. of a(n) shifted right: L(chi_2(4),s) = beta(s) = (1-2^(-s))*(d.g.f. of A034947), see comments by Lang and Forgues. - Ralf Stephan, Mar 27 2015
a(n) = cos(3*n*Pi/2). - Ridouane Oudra, Sep 29 2024

A002324 Number of divisors of n == 1 (mod 3) minus number of divisors of n == 2 (mod 3).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Coefficients of Dedekind zeta function for the quadratic number field of discriminant -3. See Formula section for the general expression. - N. J. A. Sloane, Mar 22 2022
Coefficients in expansion of Dirichlet series Product_p (1 - (Kronecker(m,p) + 1)*p^(-s) + Kronecker(m,p) * p^(-2s))^(-1) for m = -3.
(Number of points of norm n in hexagonal lattice) / 6, n>0.
The hexagonal lattice is the familiar 2-dimensional lattice (A_2) in which each point has 6 neighbors. This is sometimes called the triangular lattice.
The first occurrence of a(n) = 1, 2, 3, 4,... is at n= 1, 7, 49, 91, 2401, 637, ... as tabulated in A343771. - R. J. Mathar, Sep 21 2024

Examples

			G.f. = x + x^3 + x^4 + 2*x^7 + x^9 + x^12 + 2*x^13 + x^16 + 2*x^19 + 2*x^21 + ...
		

References

  • J. H. Conway and N. J. A. Sloane, "Sphere Packings, Lattices and Groups", Springer-Verlag, p. 112, first display.
  • J. W. L. Glaisher, Table of the excess of the number of (3k+1)-divisors of a number over the number of (3k+2)-divisors, Messenger Math., 31 (1901), 64-72.
  • D. H. Lehmer, Guide to Tables in the Theory of Numbers. Bulletin No. 105, National Research Council, Washington, DC, 1941, pp. 7-10.
  • 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

Dedekind zeta functions for imaginary quadratic number fields of discriminants -3, -4, -7, -8, -11, -15, -19, -20 are A002324, A002654, A035182, A002325, A035179, A035175, A035171, A035170, respectively.
Dedekind zeta functions for real quadratic number fields of discriminants 5, 8, 12, 13, 17, 21, 24, 28, 29, 33, 37, 40 are A035187, A035185, A035194, A035195, A035199, A035203, A035188, A035210, A035211, A035215, A035219, A035192, respectively.

Programs

  • Haskell
    a002324 n = a001817 n - a001822 n  -- Reinhard Zumkeller, Nov 26 2011
    
  • Maple
    A002324 := proc(n)
        local a,pe,p,e;
        a :=1 ;
        for pe in ifactors(n)[2] do
            p := op(1,pe) ;
            e := op(2,pe) ;
            if p = 3 then
                ;
            elif modp(p,3) = 1 then
                a := a*(e+1) ;
            else
                a := a*(1+(-1)^e)/2 ;
            end if;
        end do:
        a ;
    end proc:
    seq(A002324(n),n=1..100) ; # R. J. Mathar, Sep 21 2024
  • Mathematica
    dn12[n_]:=Module[{dn=Divisors[n]},Count[dn,?(Mod[#,3]==1&)]-Count[ dn,?(Mod[#,3]==2&)]]; dn12/@Range[120]  (* Harvey P. Dale, Apr 26 2011 *)
    a[ n_] := If[ n < 1, 0, DivisorSum[ n, KroneckerSymbol[ -3, #] &]]; (* Michael Somos, Aug 24 2014 *)
    Table[DirichletConvolve[DirichletCharacter[3,2,m],1,m,n],{n,1,30}] (* Steven Foster Clark, May 29 2019 *)
    f[3, p_] := 1; f[p_, e_] := If[Mod[p, 3] == 1, e+1, (1+(-1)^e)/2]; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* Amiram Eldar, Sep 17 2020 *)
  • PARI
    {a(n) = if( n<0, 0, polcoeff( sum(k=1, n, x^k / (1 + x^k + x^(2*k)), x * O(x^n)), n))}; \\ Michael Somos
    
  • PARI
    {a(n) = if( n<1, 0, sumdiv(n, d, (d%3==1) - (d%3==2)))};
    
  • PARI
    {a(n) = local(A, p, e); if( n<1, 0, A = factor(n); prod(k=1, matsize(A)[1], if( p=A[k,1], e=A[k,2]; if( p==3, 1, if( p%3==1, e+1, !(e%2))))))}; \\ Michael Somos, May 20 2005
    
  • PARI
    {a(n) = if( n<1, 0, qfrep([2,1; 1,2], n, 1)[n] / 3)}; \\ Michael Somos, Jun 05 2005
    
  • PARI
    {a(n) = if( n<1, 0, direuler(p=2, n, 1 / (1 - X) / (1 - kronecker(-3, p)*X))[n])}; \\ Michael Somos, Jun 05 2005
    
  • PARI
    my(B=bnfinit(x^2+x+1)); vector(100,n,#bnfisintnorm(B,n)) \\ Joerg Arndt, Jun 01 2024
    
  • Python
    from math import prod
    from sympy import factorint
    def A002324(n): return prod(e+1 if p%3==1 else int(not e&1) for p, e in factorint(n).items() if p != 3) # Chai Wah Wu, Nov 17 2022

Formula

From N. J. A. Sloane, Mar 22 2022 (Start):
The Dedekind zeta function DZ_K(s) for a quadratic field K of discriminant D is as follows.
Here m is defined by K = Q(sqrt(m)) (so m=D/4 if D is a multiple of 4, otherwise m=D).
DZ_K(s) is the product of three terms:
(a) Product_{odd primes p | D} 1/(1-1/p^s)
(b) Product_{odd primes p such that (D|p) = -1} 1/(1-1/p^(2s))
(c) Product_{odd primes p such that (D|p) = 1} 1/(1-1/p^s)^2
and if m is
0,1,2,3,4,5,6,7 mod 8, the prime 2 is to be included in term
-,c,a,a,-,b,a,a, respectively.
For Maple (and PARI) implementations, see link. (End)
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = u^2 - 3*v^2 + 4*w^2 - 2*u*w + w - v. - Michael Somos, Jul 20 2004
Has a nice Dirichlet series expansion, see PARI line.
G.f.: Sum_{k>0} x^k/(1+x^k+x^(2*k)). - Vladeta Jovovic, Dec 16 2002
a(3*n + 2) = 0, a(3*n) = a(n), a(3*n + 1) = A033687(n). - Michael Somos, Apr 04 2003
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^3), A(x^6)) where f(u1, u2, u3, u6) = (u1 - u3)*(u3 - u6) - (u2 - u6)^2. - Michael Somos, May 20 2005
Multiplicative with a(3^e) = 1, a(p^e) = e+1 if p == 1 (mod 3), a(p^e) = (1+(-1)^e)/2 if p == 2 (mod 3). - Michael Somos, May 20 2005
G.f.: Sum_{k>0} x^(3*k - 2) / (1 - x^(3*k - 2)) - x^(3*k - 1) / (1 - x^(3*k - 1)). - Michael Somos, Nov 02 2005
G.f.: Sum_{n >= 1} q^(n^2)(1-q)(1-q^2)...(1-q^(n-1))/((1-q^(n+1))(1-q^(n+2))...(1-q^(2n))). - Jeremy Lovejoy, Jun 12 2009
a(n) = A001817(n) - A001822(n). - R. J. Mathar, Mar 31 2011
A004016(n) = 6*a(n) unless n=0.
Dirichlet g.f.: zeta(s)*L(chi_2(3),s), with chi_2(3) the nontrivial Dirichlet character modulo 3 (A102283). - Ralf Stephan, Mar 27 2015
From Andrey Zabolotskiy, May 07 2018: (Start)
a(n) = Sum_{ m: m^2|n } A000086(n/m^2).
a(A003136(m)) > 0, a(A034020(m)) = 0 for all m. (End)
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = Pi/(3*sqrt(3)) = 0.604599... (A073010). - Amiram Eldar, Oct 11 2022

Extensions

More terms from David Radcliffe
Somos D.g.f. replaced with correct version by Ralf Stephan, Mar 27 2015

A008441 Number of ways of writing n as the sum of 2 triangular numbers.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Ramanujan theta functions: f(q) (see A121373), phi(q) (A000122), psi(q) (A010054), chi(q) (A000700). The present sequence gives the expansion coefficients of psi(q)^2.
Also the number of positive odd solutions to equation x^2 + y^2 = 8*n + 2. - Seiichi Manyama, May 28 2017

Examples

			G.f. = 1 + 2*x + x^2 + 2*x^3 + 2*x^4 + 3*x^6 + 2*x^7 + 2*x^9 + 2*x^10 + 2*x^11 + ...
G.f. for B(q) = q * A(q^4) = q + 2*q^5 + q^9 + 2*q^13 + 2*q^17 + 3*q^25 + 2*q^29 + 2*q^37 + 2*q^41 + ...
		

References

  • B. C. Berndt, Ramanujan's Notebooks Part III, Springer-Verlag. See p. 139 Example (iv).
  • J. H. Conway and N. J. A. Sloane, "Sphere Packings, Lattices and Groups", Springer-Verlag, p. 102.
  • R. W. Gosper, Strip Mining in the Abandoned Orefields of Nineteenth Century Mathematics, in Computers in Mathematics (Ed. D. V. Chudnovsky and R. D. Jenks). New York: Dekker, 1990. See p. 279.
  • R. W. Gosper, Experiments and discoveries in q-trigonometry, in Symbolic Computation, Number Theory, Special Functions, Physics and Combinatorics. Editors: F. G. Garvan and M. E. H. Ismail. Kluwer, Dordrecht, Netherlands, 2001, pp. 79-105. [See Pi_q.]
  • P. A. MacMahon, Combinatory Analysis, Cambridge Univ. Press, London and New York, Vol. 1, 1915 and Vol. 2, 1916. See vol. 2, p 31, Article 272.
  • Ivan Niven, Herbert S. Zuckerman and Hugh L. Montgomery, An Introduction to the Theory Of Numbers, Fifth Edition, John Wiley and Sons, Inc., NY 1991, p. 165.

Crossrefs

Cf. A004020, A005883, A104794, A052343, A199015 (partial sums).
Number of ways of writing n as a sum of k triangular numbers, for k=1,...: A010054, A008441, A008443, A008438, A008439, A008440, A226252, A007331, A226253, A226254, A226255, A014787, A014809.
Cf. A274621 (reciprocal series).

Programs

  • Haskell
    a052343 = (flip div 2) . (+ 1) . a008441
    -- Reinhard Zumkeller, Jul 25 2014
    
  • Magma
    A := Basis( ModularForms( Gamma1(8), 1), 420); A[2]; /* Michael Somos, Jan 31 2015 */
  • Maple
    sigmamr := proc(n,m,r) local a,d ; a := 0 ; for d in numtheory[divisors](n) do if modp(d,m) = r then a := a+1 ; end if; end do: a; end proc:
    A002654 := proc(n) sigmamr(n,4,1)-sigmamr(n,4,3) ; end proc:
    A008441 := proc(n) A002654(4*n+1) ; end proc:
    seq(A008441(n),n=0..90) ; # R. J. Mathar, Mar 23 2011
  • Mathematica
    Plus@@((-1)^(1/2 (Divisors[4#+1]-1)))& /@ Range[0, 104] (* Ant King, Dec 02 2010 *)
    a[ n_] := SeriesCoefficient[ (1/2) EllipticTheta[ 2, 0, q] EllipticTheta[ 3, 0, q], {q, 0, n + 1/4}]; (* Michael Somos, Jun 19 2012 *)
    a[ n_] := SeriesCoefficient[ (1/4) EllipticTheta[ 2, 0, q]^2, {q, 0, 2 n + 1/2}]; (* Michael Somos, Jun 19 2012 *)
    a[ n_] := If[ n < 0, 0, DivisorSum[ 4 n + 1, (-1)^Quotient[#, 2] &]];  (* Michael Somos, Jun 08 2014 *)
    QP = QPochhammer; s = QP[q^2]^4/QP[q]^2 + O[q]^100; CoefficientList[s, q] (* Jean-François Alcover, Nov 27 2015, adapted from PARI *)
    TriangleQ[n_] := IntegerQ@Sqrt[8n +1]; Table[Count[FrobeniusSolve[{1, 1}, n], {?TriangleQ}], {n, 0, 104}] (* Robert G. Wilson v, Apr 15 2017 *)
  • PARI
    {a(n) = if( n<1, n==0, polcoeff( sum(k=0, (sqrtint(8*n + 1) - 1)\2, x^(k * (k+1)/2), x * O(x^n))^2, n) )};
    
  • PARI
    {a(n) = if( n<0, 0, n = 4*n + 1; sumdiv(n, d, (-1)^(d\2)))}; /* Michael Somos, Sep 02 2005 */
    
  • PARI
    {a(n) = my(A); if( n<0, 0, A = x * O(x^n); polcoeff( eta(x^2 + A)^4 / eta(x + A)^2, n))};
    
  • PARI
    {a(n) = if( n<0, 0, n = 4*n + 1; sumdiv( n, d, (d%4==1) - (d%4==3)))}; /* Michael Somos, Sep 14 2005 */
    
  • PARI
    { my(q='q+O('q^166)); Vec(eta(q^2)^4 / eta(q)^2) } \\ Joerg Arndt, Apr 16 2017
    
  • Sage
    ModularForms( Gamma1(8), 1, prec=420).1; # Michael Somos, Jun 08 2014
    

Formula

This sequence is the quadrisection of many sequences. Here are two examples:
a(n) = A002654(4n+1), the difference between the number of divisors of 4*n+1 of form 4*k+1 and the number of form 4*k-1. - David Broadhurst, Oct 20 2002
a(n) = b(4*n + 1), where b(n) is multiplicative and b(2^e) = 0^e, b(p^e) = (1 + (-1)^e) / 2 if p == 3 (mod 4), b(p^e) = e+1 if p == 1 (mod 4). - Michael Somos, Sep 14 2005
G.f.: (Sum_{k>=0} x^((k^2 + k)/2))^2 = (Sum_{k>=0} x^(k^2 + k)) * (Sum_{k in Z} x^(k^2)).
Expansion of Jacobi theta (theta_2(0, sqrt(q)))^2 / (4 * q^(1/4)).
Sum[d|(4n+1), (-1)^((d-1)/2) ].
Given g.f. A(x), then B(q) = q * A(q^4) satisfies 0 = f(B(q), B(q^2), B(q^4)) where f(u, v, w) = v^3 + 4 * v * w^2 - u^2 * w. - Michael Somos, Sep 14 2005
Given g.f. A(x), then B(q) = q * A(q^4) satisfies 0 = f(B(q), B(q^2), B(q^3), B(q^6)) where f(u1, u2, u3, u6) = u1 * u3 - (u2 - u6) * (u2 + 3*u6). - Michael Somos, Sep 14 2005
Expansion of Jacobi k/(4*q^(1/2)) * (2/Pi)* K(k) in powers of q^2. - Michael Somos, Sep 14 2005. Convolution of A001938 and A004018. This appears in the denominator of the Jacobi sn and cn formula given in the Abramowitz-Stegun reference, p. 575, 16.23.1 and 16.23.2, where m=k^2. - Wolfdieter Lang, Jul 05 2016
G.f.: Sum_{k>=0} a(k) * x^(2*k) = Sum_{k>=0} x^k / (1 + x^(2*k + 1)).
G.f.: Sum_{k in Z} x^k / (1 - x^(4*k + 1)). - Michael Somos, Nov 03 2005
Expansion of psi(x)^2 = phi(x) * psi(x^2) in powers of x where phi(), psi() are Ramanujan theta functions.
Moebius transform is period 8 sequence [ 1, -1, -1, 0, 1, 1, -1, 0, ...]. - Michael Somos, Jan 25 2008
G.f. is a period 1 Fourier series which satisfies f(-1 / (8 t)) = 1/2 (t/i) g(t) where q = exp(2 Pi i t) and g() is the g.f. for A104794.
Euler transform of period 2 sequence [ 2, -2, ...].
G.f.: q^(-1/4) * eta(q^2)^4 / eta(q)^2. See also the Fine reference.
a(n) = Sum_{k=0..n} A010054(k)*A010054(n-k). - Reinhard Zumkeller, Nov 03 2009
A004020(n) = 2 * a(n). A005883(n) = 4 * a(n).
Convolution square of A010054.
G.f.: Product_{k>0} (1 - x^(2*k))^2 / (1 - x^(2*k-1))^2.
a(2*n) = A113407(n). a(2*n + 1) = A053692(n). a(3*n) = A002175(n). a(3*n + 1) = 2 * A121444(n). a(9*n + 2) = a(n). a(9*n + 5) = a(9*n + 8) = 0. - Michael Somos, Jun 08 2014
G.f.: exp( Sum_{n>=1} 2*(x^n/n) / (1 + x^n) ). - Paul D. Hanna, Mar 01 2016
a(n) = A001826(2+8*n) - A001842(2+8*n), the difference between the number of divisors 1 (mod 4) and 3 (mod 4) of 2+8*n. See the Ono et al. link, Corollary 1, or directly the Niven et al. reference, p. 165, Corollary (3.23). - Wolfdieter Lang, Jan 11 2017
Expansion of continued fraction 1 / (1 - x^1 + x^1*(1 - x^1)^2 / (1 - x^3 + x^2*(1 - x^2)^2 / (1 - x^5 + x^3*(1 - x^3)^2 / ...))) in powers of x^2. - Michael Somos, Apr 20 2017
Given g.f. A(x), and B(x) is the g.f. for A079006, then B(x) = A(x^2) / A(x) and B(x) * B(x^2) * B(x^4) * ... = 1 / A(x). - Michael Somos, Apr 20 2017
a(0) = 1, a(n) = (2/n)*Sum_{k=1..n} A002129(k)*a(n-k) for n > 0. - Seiichi Manyama, May 06 2017
From Paul D. Hanna, Aug 10 2019: (Start)
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(2*n+1) - x^(2*k))^(n-k) = Sum_{n>=0} a(n)*x^(2*n).
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(2*n+1) + x^(2*k))^(n-k) * (-1)^k = Sum_{n>=0} a(n)*x^(2*n). (End)
From Peter Bala, Jan 05 2021: (Start)
G.f.: Sum_{n = -oo..oo} x^(4*n^2+2*n) * (1 + x^(4*n+1))/(1 - x^(4*n+1)). See Agarwal, p. 285, equation 6.20 with i = j = 1 and mu = 4.
For prime p of the form 4*k + 3, a(n*p^2 + (p^2 - 1)/4) = a(n).
If n > 0 and p are coprime then a(n*p + (p^2 - 1)/4) = 0. The proofs are similar to those given for the corresponding results for A115110. Cf. A000729.
For prime p of the form 4*k + 1 and for n not congruent to (p - 1)/4 (mod p) we have a(n*p^2 + (p^2 - 1)/4) = 3*a(n) (since b(n), where b(4*n+1) = a(n), is multiplicative). (End)
From Peter Bala, Mar 22 2021: (Start)
G.f. A(q) satisfies:
A(q^2) = Sum_{n = -oo..oo} q^n/(1 - q^(4*n+2)) (set z = q, alpha = q^2, mu = 4 in Agarwal, equation 6.15).
A(q^2) = Sum_{n = -oo..oo} q^(2*n)/(1 - q^(4*n+1)) (set z = q^2, alpha = q, mu = 4 in Agarwal, equation 6.15).
A(q^2) = Sum_{n = -oo..oo} q^n/(1 + q^(2*n+1))^2 = Sum_{n = -oo..oo} q^(3*n+1)/(1 + q^(2*n+1))^2. (End)
G.f.: Sum_{k>=0} a(k) * q^k = Sum_{k>=0} (-1)^k * q^(k*(k+1)) + 2 * Sum_{n>=1, k>=0} (-1)^k * q^(k*(k+2*n+1)+n). - Mamuka Jibladze, May 17 2021
G.f.: Sum_{k>=0} a(k) * q^k = Sum_{k>=0} (-1)^k * q^(k*(k+1)) * (1 + q^(2*k+1))/(1 - q^(2*k+1)). - Mamuka Jibladze, Jun 06 2021
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = Pi/2 (A019669). - Amiram Eldar, Oct 15 2022

Extensions

More terms and information from Michael Somos, Mar 23 2003

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
Showing 1-10 of 104 results. Next