A158092 Number of solutions to +- 1 +- 2^2 +- 3^2 +- 4^2 +- ... +- n^2 = 0.
0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 10, 0, 0, 86, 114, 0, 0, 478, 860, 0, 0, 5808, 10838, 0, 0, 55626, 100426, 0, 0, 696164, 1298600, 0, 0, 7826992, 14574366, 0, 0, 100061106, 187392994, 0, 0, 1223587084, 2322159814, 0, 0, 16019866270, 30353305134, 0, 0
Offset: 1
Keywords
Examples
For n=8 the a(8)=2 solutions are: +1-4-9+16-25+36+49-64=0 and -1+4+9-16+25-36-49+64=0.
Links
- Alois P. Heinz and Ray Chandler, Table of n, a(n) for n = 1..500 (first 240 terms from Alois P. Heinz)
- D. Andrica and E. J. Ionascu, Variations on a result of Erdős and Surányi, INTEGERS 2013 slides.
- Dorin Andrica and Ioan Tomescu, On an Integer Sequence Related to a Product of Trigonometric Functions, and Its Combinatorial Relevance, J. Integer Sequences, 5 (2002), Article 02.2.4.
- P. Erdős and J. Surányi, Egy additív számelméleti probléma (in Hungarian; Russian and German summaries), Mat. Lapok 10 (1959), pp. 284-290.
Programs
-
Maple
From Pietro Majer, Mar 15 2009: (Start) N:=60: p:=1: a:=[]: for n from 1 to N do p:=expand(p*(x^(n^2)+x^(-n^2))): a:=[op(a), coeff(p, x, 0)]: od:a; (End) # second Maple program: b:= proc(n, i) option remember; local m; m:= (1+(3+2*i)*i)*i/6; `if`(n>m, 0, `if`(n=m, 1, b(abs(n-i^2), i-1) +b(n+i^2, i-1))) end: a:= n-> `if`(irem(n-1, 4)<2, 0, 2*b(n^2, n-1)): seq(a(n), n=1..60); # Alois P. Heinz, Nov 05 2012
-
Mathematica
b[n_, i_] := b[n, i] = With[{m = (1+(3+2*i)*i)*i/6}, If[n>m, 0, If[n == m, 1, b[ Abs[n-i^2], i-1] + b[n+i^2, i-1]]]]; a[n_] := If[Mod[n-1, 4]<2, 0, 2*b[n^2, n-1]]; Table[a[n], {n, 1, 60}] (* Jean-François Alcover, Mar 13 2015, after Alois P. Heinz *)
-
PARI
a(n)=2*sum(i=0,2^(n-1)-1,sum(j=1,n-1,(-1)^bittest(i,j-1)*j^2)==n^2) \\ Charles R Greathouse IV, Nov 05 2012
-
Python
from itertools import count, islice from collections import Counter def A158092_gen(): # generator of terms ccount = Counter({0:1}) for i in count(1): bcount = Counter() for a in ccount: bcount[a+(j:=i**2)] += ccount[a] bcount[a-j] += ccount[a] ccount = bcount yield(ccount[0]) A158092_list = list(islice(A158092_gen(),20)) # Chai Wah Wu, Jan 29 2024
Formula
Constant term in the expansion of (x + 1/x)(x^4 + 1/x^4)..(x^n^2 + 1/x^n^2).
a(n)=0 for any n == 1 or 2 (mod 4).
Integral representation: a(n)=((2^n)/pi)*int_0^pi prod_{k=1}^n cos(x*k^2) dx
Asymptotic formula: a(n) = (2^n)*sqrt(10/(pi*n^5))*(1+o(1)) as n-->infty; n == -1 or 0 (mod 4).
min{n : a(n) > 0} = A231015(0) = 7. - Jonathan Sondow, Nov 06 2013
Extensions
a(51)-a(56) from R. H. Hardin, Mar 12 2009
Edited by N. J. A. Sloane, Sep 15 2009
Comments