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

A025591 Maximal coefficient of Product_{k<=n} (1 + x^k). Number of solutions to +- 1 +- 2 +- 3 +- ... +- n = 0 or 1.

Original entry on oeis.org

1, 1, 1, 2, 2, 3, 5, 8, 14, 23, 40, 70, 124, 221, 397, 722, 1314, 2410, 4441, 8220, 15272, 28460, 53222, 99820, 187692, 353743, 668273, 1265204, 2399784, 4559828, 8679280, 16547220, 31592878, 60400688, 115633260, 221653776, 425363952, 817175698
Offset: 0

Views

Author

Keywords

Comments

If k is allowed to approach infinity, this gives the partition numbers A000009.
a(n) is the maximal number of subsets of {1,2,...,n} that share the same sum.

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n>i*(i+1)/2, 0,
          `if`(i=0, 1, b(n+i, i-1)+b(abs(n-i), i-1)))
        end:
    a:=n-> b(0, n)+b(1, n):
    seq(a(n), n=0..40);  # Alois P. Heinz, Mar 10 2014
  • Mathematica
    f[n_, s_] := f[n, s]=Which[n==0, If[s==0, 1, 0], Abs[s]>(n*(n+1))/2, 0, True, f[n-1, s-n]+f[n-1, s+n]]; Table[Which[Mod[n, 4]==0||Mod[n, 4]==3, f[n, 0], Mod[n, 4]==1||Mod[n, 4]==2, f[n, 1]], {n, 0, 40}]
    (* Second program: *)
    p = 1; Flatten[{1, Table[p = Expand[p*(1 + x^n)]; Max[CoefficientList[p, x]], {n, 1, 50}]}] (* Vaclav Kotesovec, May 04 2018 *)
    b[n_, i_] := b[n, i] = If[n > i(i+1)/2, 0, If[i == 0, 1, b[n+i, i-1] + b[Abs[n-i], i-1]]];
    a[n_] := b[0, n] + b[1, n]; a /@ Range[0, 40] (* Jean-François Alcover, Feb 17 2020, after Alois P. Heinz *)
  • PARI
    a(n)=if(n<0,0,polcoeff(prod(k=1,n,1+x^k),n*(n+1)\4))
    
  • Python
    from collections import Counter
    def A025591(n):
        c = {0:1,1:1}
        for i in range(2,n+1):
            d = Counter(c)
            for k in c:
                d[k+i] += c[k]
            c = d
        return max(c.values()) # Chai Wah Wu, Jan 31 2024

Formula

a(n) = A063865(n) + A063866(n).
a(n) ~ sqrt(6/Pi) * 2^n / n^(3/2) [conjectured by Andrica and Tomescu (2002) and proved by Sullivan (2013)]. - Vaclav Kotesovec, Mar 17 2020
More precise asymptotics: a(n) ~ sqrt(6/Pi) * 2^n / n^(3/2) * (1 - 6/(5*n) + 589/(560*n^2) - 39/(50*n^3) + ...). - Vaclav Kotesovec, Dec 30 2022
a(n) = max_{k>=0} A053632(n,k). - Alois P. Heinz, Jan 20 2023

A083309 a(n) is the number of times that sums 3 +- 5 +- 7 +- 11 +- ... +- prime(2n+1) of the first 2n odd primes is zero. There are 2^(2n-1) choices for the sign patterns.

Original entry on oeis.org

0, 0, 1, 2, 7, 19, 63, 197, 645, 2172, 7423, 25534, 89218, 317284, 1130526, 4033648, 14515742, 52625952, 191790090, 702333340, 2585539586, 9570549372, 35562602950, 131774529663, 491713178890, 1842214901398, 6909091641548
Offset: 1

Views

Author

T. D. Noe, Apr 29 2003

Keywords

Comments

The frequency of each possible sum is computed by the Mathematica program without explicitly computing the individual sums. Let S = 3 + 5 + 7 + ... + prime(2n+1). Because the primes do not grow very fast, it is easy to show that, for n > 2, all even numbers between -S+20 and S-20 occur at least once as a sum.
a(n) is the maximal number of subsets of {prime(2), prime(3), ..., prime(n+1)} that share the same sum. Cf. A025591, A083527.
See A238894 for a more general sequence that looks at all sums formed. - T. D. Noe, Mar 07 2014

Examples

			a(3) = 1 because there is only one sign pattern of the first six odd primes that yields zero: 3 + 5 + 7 - 11 + 13 - 17.
		

Crossrefs

Cf. A022894 (use all primes in the sum), A022895 (r.h.s. = 1), A022896 (r.h.s. = 2), A022897 (interleaved 0 for odd number of terms), ..., A022903 (using primes >= 7), A022904, A022920; A261061 - A261063 and A261044 (r.h.s. = -1); A261057, A261059, A261060, A261045 (r.h.s. = -2).

Programs

  • Mathematica
    d={1, 0, 0, 1}; nMax=32; zeroLst={}; Do[p=Prime[n+1]; d=PadLeft[d, Length[d]+p]+PadRight[d, Length[d]+p]; If[0==Mod[n, 2], AppendTo[zeroLst, d[[(Length[d]+1)/2]]]], {n, 2, nMax}]; zeroLst/2
  • PARI
    A083309(n, rhs=0, firstprime=2)={rhs-=prime(firstprime); my(p=vector(2*n-2+bittest(rhs, 0), i, prime(i+firstprime))); sum(i=1, 2^#p-1, sum(j=1, #p, (-1)^bittest(i, j-1)*p[j])==rhs)} \\ For illustrative purpose, too slow for n >> 10. - M. F. Hasler, Aug 08 2015

Formula

a(n) = A022897(2n). - M. F. Hasler, Aug 08 2015

A158092 Number of solutions to +- 1 +- 2^2 +- 3^2 +- 4^2 +- ... +- n^2 = 0.

Original entry on oeis.org

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

Views

Author

Pietro Majer, Mar 12 2009

Keywords

Comments

Twice A083527.
Number of partitions of the half of the n-th-square-pyramidal number into parts that are distinct square numbers in the range 1 to n^2. Example: a(7)=2 since, squarePyramidal(7)=140 and 70=1+4+16+49=9+25+36. - Hieronymus Fischer, Oct 20 2010
Erdős & Surányi prove that this sequence is unbounded. More generally, there are infinitely many ways to write a given number k as such a sum. - Charles R Greathouse IV, Nov 05 2012
The expansion and integral representation formulas below are due to Andrica & Tomescu. The asymptotic formula is a conjecture; see Andrica & Ionascu. - Jonathan Sondow, Nov 11 2013

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.
		

Crossrefs

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).
a(n) = 2 * A083527(n). - T. D. Noe, Mar 12 2009
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

A113263 a(n) is the number of ways the set {1^3, 2^3, ..., n^3} can be partitioned into two sets of equal sums.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 0, 0, 2, 62, 0, 0, 268, 356, 0, 0, 2287, 1130, 0, 0, 5317, 36879, 0, 0, 203016, 319415, 0, 0, 2124580, 1631750, 0, 0, 10953868, 41280525, 0, 0, 242899218, 472958485, 0, 0, 2984270739, 3419746788, 0, 0
Offset: 1

Views

Author

Floor van Lamoen, Oct 21 2005

Keywords

Comments

a(n)=0 when n == 1 or 2 mod 4.

Crossrefs

Programs

  • Maple
    A113263:=proc(n) local i,p,t; t:= NULL; p:=1; for i to n do p:=p*(x^(i^3)+x^(-i^3)); t:=t,coeff(p,x,0)/2; od; t; end;
  • Mathematica
    p = 1; t = {}; Do[p = Expand[p(x^(n^3) + x^(-n^3))]; AppendTo[t, Select[ p, NumberQ[ # ] &]/2], {n, 56}]; t (* Robert G. Wilson v *)

Formula

a(n) is half the coefficient of x^0 in product(x^(k^3)+x^(k^-3), k=1..n).
a(n) = [x^(n^3)] Product_{k=1..n-1} (x^(k^3) + 1/x^(k^3)). - Ilya Gutkovskiy, Feb 01 2024

Extensions

More terms from Robert G. Wilson v and Tony Noe, Oct 27 2005

A231071 Number of solutions to n = +- 1^2 +- 2^2 +- 3^2 +- 4^2 +- ... +- k^2 for minimal k giving at least one solution.

Original entry on oeis.org

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

Views

Author

Alois P. Heinz, Nov 03 2013

Keywords

Comments

This type of sequence was first studied by Andrica and Vacaretu. - Jonathan Sondow, Nov 06 2013

Examples

			a(8) = 3: 8 = -1-4-9-16+25-36+49 = -1-4+9+16-25-36+49 = -1+4+9-16+25+36-49.
a(9) = 2: 9 = -1-4+9+16+25-36 = 1+4+9-16-25+36.
a(10) = 1: 10 = -1+4-9+16.
		

Crossrefs

Cf. A083527, A158092 (extremal sums).

Programs

  • Maple
    b:= proc(n, i) option remember; (m->`if`(n>m, 0, `if`(n=m, 1,
          b(n+i^2, i-1) +b(abs(n-i^2), i-1))))((1+(3+2*i)*i)*i/6)
        end:
    a:= proc(n) local k; for k while b(n, k)=0 do od; b(n, k) end:
    seq(a(n), n=0..100);
  • Mathematica
    b[n_, i_] := b[n, i] = Function[m, If[n > m, 0, If[n == m, 1,
       b[n+i^2, i-1] + b[Abs[n-i^2], i-1]]]][(1+(3+2*i)*i)*i/6];
    a[n_] := Module[{k}, For[k = 1, b[n, k] == 0, k++]; b[n, k]];
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Sep 01 2022, after Alois P. Heinz *)

Formula

From Jonathan Sondow, Nov 03 2013: (Start)
a(n(n+1)(2n+1)/6) = 1 for n > 0: n(n+1)(2n+1)/6 = 1+4+9+...+n^2. See A000330.
a(n(n+1)(2n+1)/6 - 2) = 1 for n > 1: n(n+1)(2n+1)/6 - 2 = -1+4+9+...+n^2. (End)

A111253 a(n) is the number of ways the set {1^4, 2^4, ..., n^4} can be partitioned into two sets of equal sums.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 9, 0, 0, 16, 50, 0, 0, 212, 255, 0, 0, 1396, 2994, 0, 0, 14529, 22553, 0, 0, 138414, 236927, 0, 0, 1227670, 2388718, 0, 0, 13733162, 23214820, 0, 0, 140197641, 263244668, 0, 0, 1596794975, 2830613464, 0, 0
Offset: 1

Views

Author

Robert G. Wilson v, Oct 31 2005

Keywords

Comments

a(n)=0 when n == 1 or 2 (mod 4).

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; local m;
          m:= (-1+(10+(15+6*i)*i)*i^2)*i/30;
          `if`(n>m, 0, `if`(n=m, 1, b(abs(n-i^4), i-1) +b(n+i^4, i-1)))
        end:
    a:= n-> `if`(irem(n-1, 4)<2, 0, b(n^4, n-1)):
    seq(a(n), n=1..38);  # Alois P. Heinz, Oct 30 2011
  • Mathematica
    d = {1, 1}; nMax=50; zeroLst = {0}; Do[p = n^4; d = PadLeft[d, Length[d] + p] + PadRight[d, Length[d] + p]; If[1 == Mod[Length[d], 2], AppendTo[zeroLst, d[[(Length[d] + 1)/2]]], AppendTo[zeroLst, 0]], {n, 2, nMax}]; zeroLst/2 (* T. D. Noe, Oct 31 2005 *)
    p = 1; t = {}; Do[p = Expand[p(x^(n^4) + x^(-n^4))]; AppendTo[t, Select[p, NumberQ[ # ] &]/2], {n, 30}]; t

Formula

a(n) is half the coefficient of x^0 in product_{k=1..n} x^(k^4)+x^(k^-4).
a(n) = [x^(n^4)] Product_{k=1..n-1} (x^(k^4) + 1/x^(k^4)). - Ilya Gutkovskiy, Feb 01 2024

Extensions

a(51)-a(54) from T. D. Noe, Nov 01 2005
Corrected a(51)-a(52) and extended up to a(58) by Alois P. Heinz, Oct 31 2011

A300268 Number of solutions to 1 +- 4 +- 9 +- ... +- n^2 == 0 (mod n).

Original entry on oeis.org

1, 0, 2, 4, 6, 0, 10, 48, 32, 0, 94, 344, 370, 0, 1268, 4608, 3856, 0, 13798, 55960, 50090, 0, 182362, 721952, 690496, 0, 2485592, 9586984, 9256746, 0, 34636834, 135335936, 130150588, 0, 493452348, 1908875264, 1857293524, 0, 7049188508, 27603824928
Offset: 1

Views

Author

Seiichi Manyama, Mar 01 2018

Keywords

Examples

			Solutions for n = 7:
-------------------------------
1 +4 +9 +16 +25 +36 +49 =  140.
1 +4 +9 +16 +25 +36 -49 =   42.
1 +4 +9 -16 -25 -36 +49 =  -14.
1 +4 +9 -16 -25 -36 -49 = -112.
1 +4 -9 +16 -25 -36 +49 =    0.
1 +4 -9 +16 -25 -36 -49 =  -98.
1 -4 +9 -16 +25 -36 +49 =   28.
1 -4 +9 -16 +25 -36 -49 =  -70.
1 -4 -9 +16 +25 -36 +49 =   42.
1 -4 -9 +16 +25 -36 -49 =  -56.
		

Crossrefs

Number of solutions to 1 +- 2^k +- 3^k +- ... +- n^k == 0 (mod n): A300190 (k=1), this sequence (k=2), A300269 (k=3).

Programs

  • Maple
    b:= proc(n, i, m) option remember; `if`(i=0, `if`(n=0, 1, 0),
          add(b(irem(n+j, m), i-1, m), j=[i^2, m-i^2]))
        end:
    a:= n-> b(0, n-1, n):
    seq(a(n), n=1..60);  # Alois P. Heinz, Mar 01 2018
  • Mathematica
    b[n_, i_, m_] := b[n, i, m] = If[i == 0, If[n == 0, 1, 0],
         Sum[b[Mod[n + j, m], i - 1, m], {j, {i^2, m - i^2}}]];
    a[n_] := b[0, n - 1, n];
    Table[a[n], {n, 1, 60}] (* Jean-François Alcover, Mar 19 2022, after Alois P. Heinz *)
  • PARI
    a(n) = my (v=vector(n,k,k==1)); for (i=2, n, v = vector(n, k, v[1 + (k-i^2)%n] + v[1 + (k+i^2)%n])); v[1] \\ Rémy Sigrist, Mar 01 2018
  • Ruby
    def A(n)
      ary = [1] + Array.new(n - 1, 0)
      (1..n).each{|i|
        i2 = 2 * i * i
        a = ary.clone
        (0..n - 1).each{|j| a[(j + i2) % n] += ary[j]}
        ary = a
      }
      ary[(n * (n + 1) * (2 * n + 1) / 6) % n] / 2
    end
    def A300268(n)
      (1..n).map{|i| A(i)}
    end
    p A300268(100)
    

A307877 Number of ways of partitioning the set of the first n positive squares into two subsets whose sums differ at most by 1.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 2, 1, 1, 5, 2, 1, 5, 13, 43, 43, 57, 193, 274, 239, 430, 1552, 3245, 2904, 5419, 18628, 31048, 27813, 50213, 188536, 372710, 348082, 649300, 2376996, 4197425, 3913496, 7287183, 27465147, 53072709, 50030553, 93696497, 351329160, 650125358
Offset: 0

Views

Author

Alois P. Heinz, Jun 04 2019

Keywords

Examples

			a(6) = 2: 1,9,36/4,16,25; 1,4,16,25/9,36.
a(7) = 1: 1,4,16,49/9,25,36.
		

Crossrefs

Programs

  • Maple
    s:= proc(n) s(n):= `if`(n=0, 1, n^2+s(n-1)) end:
    b:= proc(n, i) option remember; `if`(i=0, `if`(n<=1, 1, 0),
          `if`(n>s(i), 0, (p-> b(n+p, i-1)+b(abs(n-p), i-1))(i^2)))
        end:
    a:= n-> ceil(b(0, n)/2):
    seq(a(n), n=0..45);
  • Mathematica
    s[n_] := s[n] = If[n == 0, 1, n^2 + s[n - 1]];
    b[n_, i_] := b[n, i] = If[i == 0, If[n <= 1, 1, 0], If[n > s[i], 0, Function[p, b[n + p, i - 1] + b[Abs[n - p], i - 1]][i^2]]];
    a[n_] := Ceiling[b[0, n]/2];
    a /@ Range[0, 45] (* Jean-François Alcover, Dec 07 2020, after Alois P. Heinz *)

Formula

a(n) = A083527(n) if n == 0 or 3 (mod 4).

A292497 Number of solutions to 1^2 +- 3^2 +- 5^2 +- 7^2 +- ... +- (4*n-1)^2 = 0.

Original entry on oeis.org

1, 0, 0, 0, 1, 0, 6, 0, 20, 5, 258, 62, 2510, 914, 24285, 16403, 263945, 222240, 3068971, 3241157, 35286928, 46638022, 426740187, 650095127, 5330192371, 9185814630, 67064945191, 129902075662, 864443143567, 1833530501143, 11336065334984, 25990268638322
Offset: 0

Views

Author

Seiichi Manyama, Sep 17 2017

Keywords

Crossrefs

Formula

For n>0 constant term in the expansion of 1/2 * Product_{k=1..2*n} (x^(2*k-1)^2+1/x^(2*k-1)^2).
a(n) = A292496(n)/2 for n>0.

A350403 Number of solutions to +-1^2 +- 2^2 +- 3^2 +- ... +- n^2 = 0 or 1.

Original entry on oeis.org

1, 1, 0, 0, 0, 0, 2, 2, 2, 5, 2, 2, 10, 13, 43, 86, 114, 193, 274, 478, 860, 1552, 3245, 5808, 10838, 18628, 31048, 55626, 100426, 188536, 372710, 696164, 1298600, 2376996, 4197425, 7826992, 14574366, 27465147, 53072709, 100061106, 187392994, 351329160
Offset: 0

Views

Author

Ilya Gutkovskiy, Dec 29 2021

Keywords

Examples

			a(8) = 2: +1^2 - 2^2 - 3^2 + 4^2 - 5^2 + 6^2 + 7^2 - 8^2 =
          -1^2 + 2^2 + 3^2 - 4^2 + 5^2 - 6^2 - 7^2 + 8^2 = 0.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n>i*(i+1)*(2*i+1)/6, 0,
          `if`(i=0, 1, b(n+i^2, i-1)+b(abs(n-i^2), i-1)))
        end:
    a:=n-> b(0, n)+b(1, n):
    seq(a(n), n=0..42);  # Alois P. Heinz, Jan 16 2022
  • Mathematica
    b[n_, i_] := b[n, i] = If[n > i*(i + 1)*(2*i + 1)/6, 0,
         If[i == 0, 1, b[n + i^2, i - 1] + b[Abs[n - i^2], i - 1]]];
    a[n_] := b[0, n] + b[1, n];
    Table[a[n], {n, 0, 42}] (* Jean-François Alcover, Mar 01 2022, after Alois P. Heinz *)
  • Python
    from itertools import product
    def a(n):
        if n == 0: return 1
        nn = ["0"] + [str(i)+"**2" for i in range(1, n+1)]
        return sum(eval("".join([*sum(zip(nn, ops+("", )), ())])) in {0, 1} for ops in product("+-", repeat=n))
    print([a(n) for n in range(18)]) # Michael S. Branicky, Jan 16 2022
    
  • Python
    from functools import cache
    @cache
    def b(n, i):
        if n > i*(i+1)*(2*i+1)//6: return 0
        if i == 0: return 1
        return b(n+i**2, i-1) + b(abs(n-i**2), i-1)
    def a(n): return b(0, n) + b(1, n)
    print([a(n) for n in range(43)]) # Michael S. Branicky, Jan 16 2022 after Alois P. Heinz
Showing 1-10 of 11 results. Next