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.

Previous Showing 11-20 of 23 results. Next

A069918 Number of ways of partitioning the set {1...n} into two subsets whose sums are as nearly equal as possible.

Original entry on oeis.org

1, 1, 1, 1, 3, 5, 4, 7, 23, 40, 35, 62, 221, 397, 361, 657, 2410, 4441, 4110, 7636, 28460, 53222, 49910, 93846, 353743, 668273, 632602, 1199892, 4559828, 8679280, 8273610, 15796439, 60400688, 115633260, 110826888, 212681976, 817175698, 1571588177, 1512776590
Offset: 1

Views

Author

Robert G. Wilson v, Apr 24 2002

Keywords

Comments

If n mod 4 = 0 or 3, a(n) is the number of solutions to +- 1 +- 2 +- 3 +- ... +- n = 0 or 1; if n mod 4 = 1 or 2, a(n) is half this number.

Examples

			If the triangular number T_n (see A000217) is even then the two totals must be equal, otherwise the two totals differ by one.
a(6) = 5: T6 = 21 and is odd. There are five sets such that the sum of one side is equal to the other side +/- 1. They are 5+6 = 1+2+3+4, 4+6 = 1+2+3+5, 1+4+6 = 2+3+5, 1+3+6 = 2+4+5 and 2+3+6 = 1+4+5.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; local m; m:= i*(i+1)/2;
          `if`(n>m, 0, `if`(n=m, 1, b(abs(n-i), i-1) +b(n+i, i-1)))
        end:
    a:= n-> `if`(irem(n-1, 4)<2, b(n-1, n-1) +b(n+1, n-1), b(n, n-1)):
    seq(a(n), n=1..60);  # Alois P. Heinz, Nov 02 2011
  • Mathematica
    Needs["DiscreteMath`Combinatorica`"]; f[n_] := f[n] = Block[{s = Sort[Plus @@@ Subsets[n]], k = n(n + 1)/2}, If[ EvenQ[k], Count[s, k/2]/2, (Count[s, Floor[k/2]] + Count[s, Ceiling[k/2]]) /2]]; Table[ f[n], {n, 1, 22}]
    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]/2, Mod[n, 4] == 1 || Mod[n, 4] == 2, f[n, 1]], {n, 1, 40}]

Formula

If n mod 4 = 0 or 3 then the two subsets have the same sum and a(n) = A025591(n); if n mod 4 = 1 or 2 then the two subsets have sums which differ by 1 and a(n) = A025591(n)/2. - Henry Bottomley, May 08 2002

Extensions

More terms from Henry Bottomley, May 08 2002
Comment corrected by Steven Finch, Feb 01 2009

A104456 Number of ways of partitioning the integers {1,2,..,4n-1} into two unordered sets such that the sums of parts are equal in both sets (parts in one of the sets hence sum up to n*(4n-1)). Number of solutions to {1 +- 2 +- 3+ ... +- 4n-1 = 0}.

Original entry on oeis.org

1, 4, 35, 361, 4110, 49910, 632602, 8273610, 110826888, 1512776590, 20965992017, 294245741167, 4173319332859, 59723919552183, 861331863890066, 12505857230438737, 182650875111521033, 2681644149792639400, 39555354718945873299, 585903163431438401072
Offset: 1

Views

Author

Yiu Tung Poon (ytpoon(AT)iastate.edu) and Chun Chor Litwin Cheng (cccheng(AT)ied.edu.hk), Mar 08 2005

Keywords

Examples

			a(2) = 4 since there are 4 ways of partitioning {1,2,3,4,5,6,7} into two sets of equal sum, namely {{1,2,5,6}, {3,4,7}}, {{1,3,4,6}, {2,5,7}}, {{2,3,4,5}, {1,6,7}}, {{1,2,4,7}, {3,5,6}}.
G.f. = x + 4*x^2 + 35*x^3 + 361*x^4 + 4110*x^5 + 49910*x^6 + ...
		

Crossrefs

Cf. A060005.

Programs

  • Maple
    b:= proc(n, i) option remember; local m; m:= i*(i+1)/2;
          `if`(n>m, 0, `if`(n=m, 1, b(abs(n-i), i-1) +b(n+i, i-1)))
        end:
    a:= n-> b(4*n-1, 4*n-2):
    seq(a(n), n=1..30); # Alois P. Heinz, Nov 01 2011
  • Mathematica
    Table[CoefficientList[Product[1 + x^j, {j, 1, 4n - 1}], x][[n*(4n - 1) + 1]]/2, {n, 20}]

Formula

a(n) = A058377(4n-1). - N. J. A. Sloane, Jan 24 2006
a(n) is half the coefficient of q^(n*(4n - 1)) in the product('1 + x^j', 'j'=1..4*n-1), for n >= 1. - N. J. A. Sloane, Feb 24 2006
a(n) = (1/Pi)*2^(4n-1)*J(4n-1) where J(n) = integral(t=0, Pi/2, cos(t) * cos(2t) * ... * cos(nt)dt), n>=1. - Benoit Cloitre, Sep 24 2006
a(n) = A123117(n)/2. - N. J. A. Sloane, Jan 09 2009

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

A342804 Number of solutions to 1 +-*/ 2 +-*/ 3 +-*/ ... +-*/ n = 0.

Original entry on oeis.org

0, 0, 1, 1, 1, 5, 8, 18, 39, 91, 185, 460, 1051, 2526, 6280, 15645, 35516, 93765, 225989, 611503
Offset: 1

Views

Author

Scott R. Shannon, Mar 27 2021

Keywords

Comments

Normal operator precedence is followed, so multiplication and division are performed before addition or subtraction, and each operator only acts on the following term, so 2 / 3 * 4 equals (2 / 3) * 4.
Unlike A058377, which uses only addition and subtraction, this sequence has solutions for all values of n >= 3.

Examples

			a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
a(5) = 1 as 1 * 2 - 3 - 4 + 5 = 0 is the only solution. This is the first term where a solution exists while no corresponding solution exists in A058377.
a(6) = 5. The solutions, all of which use multiplication or division, are
         1 + 2 * 3 + 4 - 5 - 6 = 0,
         1 - 2 + 3 * 4 - 5 - 6 = 0,
         1 - 2 * 3 + 4 - 5 + 6 = 0,
         1 * 2 + 3 - 4 + 5 - 6 = 0,
         1 - 2 / 3 / 4 - 5 / 6 = 0.
  The last solution is the first that uses division.
a(7) = 8. Six solutions use just addition, division and multiplication. The other two are
         1 + 2 - 3 * 4 * 5 / 6 + 7 = 0,
         1 / 2 * 3 * 4 - 5 + 6 - 7 = 0.
a(15) = 6280. An example solution is
         1 / 2 / 3 / 4 * 5 * 6 - 7 - 8 + 9 / 10 + 11 / 12 * 13 + 14 / 15 = 0
  which includes four fractions that sum to 15, which is balanced by - 7 - 8.
a(20) = 611503. An example solution is
         1 / 2 / 3 / 4 / 5 + 6 / 7 / 8 / 9 / 10 * 11 / 12 - 13 / 14 / 15 / 16
              + 17 / 18 - 19 / 20 = 0
  which sums five fractions that include fourteen divisions.
		

Crossrefs

Cf. A342602 (using +-*), A342995 (using +-/), A058377 (using +-), A063865, A000217, A025591, A161943.

Programs

  • Mathematica
    Table[Length@Select[Tuples[{"+","-","*","/"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,9}] (* Giorgos Kalogeropoulos, Apr 02 2021 *)
  • Python
    from itertools import product
    from fractions import Fraction
    def a(n):
      nn = ["Fraction("+str(i)+", 1)" for i in range(1, n+1)]
      return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-*/", repeat=n-1))
    print([a(n) for n in range(1, 10)]) # Michael S. Branicky, Apr 02 2021

A113036 Number of solutions to +- 1 +- 2 +- .. +- n = 2.

Original entry on oeis.org

0, 0, 0, 1, 2, 0, 0, 8, 13, 0, 0, 69, 123, 0, 0, 719, 1313, 0, 0, 8215, 15260, 0, 0, 99774, 187615, 0, 0, 1264854, 2399207, 0, 0, 16544234, 31587644, 0, 0, 221625505, 425313967, 0, 0, 3025271756, 5829531261, 0, 0, 41929052284, 81066732018, 0
Offset: 0

Views

Author

Floor van Lamoen, Oct 11 2005

Keywords

Crossrefs

Programs

  • Maple
    A113036:= proc(n) local i,j,p,t; t:= NULL; for j to n do p:=1; for i to j do p:=p*(x^(-i)+x^i); od; t:=t,coeff(p,x,2); od; t; end;
  • Mathematica
    nmax = 50; d = {1}; a1 = {};
    Do[
      i = Ceiling[Length[d]/2] + 2;
      AppendTo[a1, If[i > Length[d], 0, d[[i]]]];
      d = PadLeft[d, Length[d] + 2 n] + PadRight[d, Length[d] + 2 n];
      , {n, nmax}];
    a1 (* Ray Chandler, Mar 14 2014 *)

Formula

a(n) is the coefficient of x^2 in product(x^(-k)+x^k, k=1..n).

A113037 Number of solutions to +- 1 +- 2 +- .. +- n = 3.

Original entry on oeis.org

0, 0, 1, 0, 0, 3, 5, 0, 0, 23, 39, 0, 0, 219, 396, 0, 0, 2406, 4435, 0, 0, 28431, 53167, 0, 0, 353500, 667874, 0, 0, 4557831, 8675836, 0, 0, 60382450, 115601178, 0, 0, 816998489, 1571272955, 0, 0, 11242173783, 21701318843, 0, 0, 156841667096
Offset: 0

Views

Author

Floor van Lamoen, Oct 11 2005

Keywords

Crossrefs

Programs

  • Maple
    A113037:= proc(n) local i,j,p,t; t:= NULL; for j to n do p:=1; for i to j do p:=p*(x^(-i)+x^i); od; t:=t,coeff(p,x,3); od; t; end;
  • Mathematica
    nmax = 50; d = {1}; a1 = {};
    Do[
      i = Ceiling[Length[d]/2] + 3;
      AppendTo[a1, If[i > Length[d], 0, d[[i]]]];
      d = PadLeft[d, Length[d] + 2 n] + PadRight[d, Length[d] + 2 n];
      , {n, nmax}];
    a1 (* Ray Chandler, Mar 14 2014 *)

Formula

a(n) is the coefficient of x^3 in product(x^(-k)+x^k, k=1..n).

A290889 Number of partitions of the set of odd numbers {1, 3, ..., 2*n-1} into two subsets such that the absolute difference of the sums of the two subsets is minimized.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 5, 4, 13, 10, 38, 34, 118, 103, 380, 346, 1262, 1153, 4277, 3965, 14745, 13746, 51541, 48396, 182182, 171835, 650095, 615966, 2338706, 2223755, 8472697, 8082457, 30884150, 29543309, 113189168, 108545916, 416839177, 400623807, 1541726967
Offset: 1

Views

Author

Hugo Pfoertner, Aug 13 2017

Keywords

Comments

Partitioning in equal sums is only possible for n = 4*k-1, k > 1, and the number of such partitions is given by A156700. For the set {1,3} and the other values of n, i.e., for the sets {1,3,5}, {1,3,5,7,9}, {1,3,5,7,9,11,13}, one can use the criterion to split the sets "as well as possible" by choosing those partitions for which the absolute value of the difference of the respective sums of the subset members achieves its minimum.

Examples

			a(1) = 1: {}U{1} with difference 1.
a(2) = 1: {1}U{3} with difference 2.
a(3) = 1: {1,3}U{5} with difference 1.
a(4) = 1 = A156700(2): {1,7}U{3,5} with difference 0.
a(5) = 2: {1,3,9}U{5,7} and {1,5,7}U{3,9} with |difference|=1.
a(6) = 1 = A156700(3): {1,3,5,9}U{7,11} with difference 0.
a(7) = 5: {1,3,5,7,9}U{11,13}, {1,3,9,11}U{5,7,13}, {1,5,7,11}U{3,9,13},
          {1,11,13}U{3,5,7,9}, {1,3,7,13}U{5,9,11} with |difference|=1.
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n>i^2, 0,
          `if`(n=i^2, 1, b(abs(n-2*i+1), i-1)+b(n+2*i-1, i-1)))
        end:
    a:= n-> `if`(n<5, 1, (t-> b(t, n)/(2-t))(irem(n, 2))):
    seq(a(n), n=1..50);  # Alois P. Heinz, Aug 14 2017
  • Mathematica
    b[n_, i_] := b[n, i] = If[n > i^2, 0, If[n == i^2, 1, b[Abs[n - 2i + 1], i - 1] + b[n + 2i - 1, i - 1]]];
    a[n_] := If[n < 5, 1, b[#, n]/(2-#)&[Mod[n, 2]]];
    Array[a, 50] (* Jean-François Alcover, Nov 14 2020, after Alois P. Heinz *)

Formula

a(n) ~ (3 - (-1)^n) * sqrt(3) * 2^(n - 5/2) / (sqrt(Pi) * n^(3/2)). - Vaclav Kotesovec, Sep 18 2017

A342602 Number of solutions to 1 +-* 2 +-* 3 +-* ... +-* n = 0.

Original entry on oeis.org

0, 0, 1, 1, 1, 4, 6, 14, 29, 63, 129, 300, 756, 1677, 4134, 9525, 22841, 57175, 141819, 354992, 882420, 2218078, 5588989, 14173217, 35918542
Offset: 1

Views

Author

Scott R. Shannon, Mar 27 2021

Keywords

Comments

Normal operator precedence is followed, so multiplication is performed before addition or subtraction. Unlike A058377, which uses only addition and subtraction, this sequence has solutions for all values of n >= 3.
The author thanks Ursula Ponting for useful discussions.

Examples

			a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
a(5) = 1 as 1 * 2 - 3 - 4 + 5 = 0 is the only solution. This is the first term where a solution exists while no corresponding solution exists in A058377.
a(6) = 4. The solutions, all of which use multiplication, are
         1 + 2 * 3 + 4 - 5 - 6 = 0,
         1 - 2 + 3 * 4 - 5 - 6 = 0,
         1 - 2 * 3 + 4 - 5 + 6 = 0,
         1 * 2 + 3 - 4 + 5 - 6 = 0.
a(10) = 63. An example solution is
         1 - 2 * 3 * 4 - 5 - 6 - 7 * 8 + 9 * 10 = 0.
a(20) = 354992. An example solution is
         1 * 2 * 3 * 4 * 5 * 6 * 7 + 8 * 9 + 10 * 11 - 12 * 13 + 14 * 15
             - 16 * 17 * 18 - 19 * 20 = 0
  which includes thirteen multiplications.
		

Crossrefs

Cf. A342804 (using +-*/), A342995 (using +-/), A058377 (using +-), A063865, A000217, A025591, A161943.

Programs

  • Mathematica
    Table[Length@Select[Tuples[{"+","-","*"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,11}] (* Giorgos Kalogeropoulos, Apr 02 2021 *)
  • Python
    from itertools import product
    def a(n):
      nn = [str(i) for i in range(1, n+1)]
      return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-*", repeat=n-1))
    print([a(n) for n in range(1, 14)]) # Michael S. Branicky, Apr 02 2021

A342995 Number of solutions to 1 +-/ 2 +-/ 3 +-/ ... +-/ n = 0.

Original entry on oeis.org

0, 0, 1, 1, 0, 1, 4, 8, 0, 3, 37, 80, 6, 17, 461, 868, 190, 364, 5570, 11342, 3993, 7307, 78644
Offset: 1

Views

Author

Scott R. Shannon, Apr 01 2021

Keywords

Comments

Normal operator precedence is followed, so division is performed before addition or subtraction. Unlike A058377, which uses only addition and subtraction, this sequence has solutions for all values of n >= 10.

Examples

			a(3) = 1 as 1 + 2 - 3 = 0 is the only solution.
a(4) = 1 as 1 - 2 - 3 + 4 = 0 is the only solution.
a(5) = 0, as in A058377.
a(6) = 1 as 1 - 2 / 3 / 4 - 5 / 6 = 0 is the only solution. This is the first term where a solution exists while no corresponding solution exists in A058377.
a(8) = 8. Seven of the solutions involve just addition and subtraction, matching those in A058377, but one additional solution exists using division:
        1 / 2 / 3 / 4 + 5 / 6 - 7 / 8 = 0.
a(10) = 3. All three solutions require division:
        1 + 2 / 3 / 4 + 5 / 6 + 7 - 8 + 9 - 10 = 0,
        1 - 2 / 3 / 4 - 5 / 6 + 7 - 8 - 9 + 10 = 0,
        1 - 2 / 3 / 4 - 5 / 6 - 7 + 8 + 9 - 10 = 0.
a(15) = 461. Of these, 361 use only addition and subtraction, the other 100 also require division. One example of the latter is
        1 / 2 / 3 / 4 - 5 - 6 - 7 / 8 + 9 / 10 + 11 + 12 - 13 + 14 / 15 = 0.
a(20) = 11342. An example solution is
        1 / 2 / 3 - 4 / 5 / 6 + 7 / 8 / 9 + 10 + 11 / 12 - 13 + 14 / 15 / 16
             + 17 / 18 + 19 / 20 = 0
  which sums seven fractions that include eleven divisions.
		

Crossrefs

Cf. A342804 (using +-*/), A342602 (using +-*), A058377 (using +-), A063865, A000217, A025591, A161943.

Programs

  • Mathematica
    Table[Length@Select[Tuples[{"+","-","/"},k-1],ToExpression[""<>Riffle[ToString/@Range@k,#]]==0&],{k,11}] (* Giorgos Kalogeropoulos, Apr 02 2021 *)
  • Python
    from itertools import product
    from fractions import Fraction
    def a(n):
      nn = ["Fraction("+str(i)+", 1)" for i in range(1, n+1)]
      return sum(eval("".join([*sum(zip(nn, ops+("",)), ())])) == 0 for ops in product("+-/", repeat=n-1))
    print([a(n) for n in range(1, 11)]) # Michael S. Branicky, Apr 02 2021

A348639 Number of ways to express n in the form 1 +- 2 +- 3 ... +- n.

Original entry on oeis.org

1, 0, 0, 1, 2, 0, 0, 6, 11, 0, 0, 57, 103, 0, 0, 615, 1131, 0, 0, 7209, 13467, 0, 0, 89261, 168515, 0, 0, 1147893, 2183943, 0, 0, 15181540, 29055149, 0, 0, 205171534, 394497990, 0, 0, 2820847321, 5444272739, 0, 0, 39329485312, 76142226498, 0, 0, 554756557011
Offset: 1

Views

Author

Daniel Cortild, Oct 26 2021

Keywords

Comments

a(n) is the coefficient of x^(n*(n+3)/4-1) of Product_{k=2..n} (1+x^k). - Jianing Song, Nov 19 2021

Crossrefs

Programs

  • C
    int solsN(int n, int k, int sum) { if (n == k) return sum == n; return solsN(n, k+1, sum + k + 1) + solsN(n, k+1, sum - k - 1);}
    int getNumber(int n) { return solsN(n, 1, 1); }
    
  • PARI
    list(n) = my(poly=vector(n), v=vector(n)); poly[1]=1; for(k=2, n, poly[k]=poly[k-1]*(1+'x^k)); for(k=1, n, if(k%4==2||k%4==3, v[k]=0, v[k]=polcoeff(poly[k], k*(k+3)/4-1))); v \\ Jianing Song, Nov 19 2021
  • Python
    from functools import cache
    @cache
    def b(t, s, u): # target, sum, upto
        if u == 1: return int(t == s + 1)
        return b(t, s - u, u - 1) + b(t, s + u, u - 1)
    def a(n): return b(n, 0, n)
    print([a(n) for n in range(1, 49)]) # Michael S. Branicky, Oct 29 2021
    

Extensions

a(30)-a(48) from Michael S. Branicky, Oct 29 2021
Previous Showing 11-20 of 23 results. Next