A124624 Erroneous version of A058377.
1, 1, 4, 7, 35, 62, 361, 657, 4110, 7636, 49910, 93846, 632602, 1199892, 8273610
Offset: 1
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.
a(6) = 3 because 1+5, 2+4 and 1+2+3 each sum to 6. That is, the three sets are {1,5},{2,4},{1,2,3}. For n=6, the partitions of 2n into distinct parts having maximum 6 are 6+5+1, 6+4+2, 6+3+2+1, so that a(6)=3, as an example for Comment (2). - _Clark Kimberling_, Mar 13 2012
a111133 = subtract 1 . a000009 -- Reinhard Zumkeller, Sep 09 2015
seq(coeff(series(mul((1+x^k),k=1..n)-1/(1-x), x,n+1),x,n),n=0..60); # Muniru A Asiru, Aug 10 2018
Needs["DiscreteMath`Combinatorica`"] f[n_] := Block[{lmt = Floor[(Sqrt[8n + 1] - 1)/2] + 1, t}, Sum[ Length[ Select[Plus @@@ KSubsets[ Range[n - k(k - 1)/2 + 1], k], # == n &]], {k, 2, lmt}]]; Array[f, 55] (* Robert G. Wilson v, Oct 17 2005 *) (* Next program shows the partitions (sets) *) d[n_] := Select[IntegerPartitions[n], Max[Length /@ Split@ #] == 1 &]; Table[d[n], {n, 1, 12}] TableForm[%] (* Clark Kimberling, Mar 13 2012 *) Table[PartitionsQ[n]-1, {n, 0, 55}] (* Jean-François Alcover, Jan 17 2014, after Vladeta Jovovic *)
N=66; x='x+O('x^N); gf=sum(k=0,N, x^((k^2+k)/2) / prod(j=1,k, 1-x^j)) - 1/(1-x); concat( [0,0,0], Vec(gf) ) /* Joerg Arndt, Sep 17 2012 */
From _Gus Wiseman_, Jul 04 2019: (Start) For example, the a(0) = 1 through a(8) = 14 subsets (empty columns not shown) are: {} {3} {1,4} {1,6,7} {3,7,8} {1,2} {2,3} {2,5,7} {4,6,8} {3,4,7} {5,6,7} {3,5,6} {1,2,7,8} {1,2,4,7} {1,3,6,8} {1,2,5,6} {1,4,5,8} {1,3,4,6} {1,4,6,7} {2,3,4,5} {2,3,5,8} {2,3,6,7} {2,4,5,7} {3,4,5,6} {1,2,3,4,8} {1,2,3,5,7} {1,2,4,5,6} (End)
M:=400; t1:=1; lprint(0,1); for n from 1 to M do t1:=expand(t1*(x^n+1/x^n)); lprint(n, coeff(t1,x,0)); od: # N. J. A. Sloane, Jul 07 2008
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]]; a[n_] := f[n, 0] nmax = 50; d = {1}; a1 = {}; Do[ i = Ceiling[Length[d]/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 13 2014 *)
a(n)=my(x='x); polcoeff(prod(k=1,n,x^k+x^-k)+O(x),0) \\ Charles R Greathouse IV, May 18 2015
a(n)=0^n+floor(prod(k=1,n,2^(n*k)+2^(-n*k)))%(2^n) \\ Tani Akinari, Mar 09 2016
a(24)=3: 1+2+3+4+8+12=6+24, 1+3+6+8+12=2+4+24, 4+6+8+12=1+2+3+24.
a[n_] := (s = DivisorSigma[1, n]; If[Mod[s, 2] == 1, 0, f[n, s/2, 2]]); f[n_, m_, k_] := f[n, m, k] = If[k <= m, f[n, m, k+1] + f[n, m-k, k+1]*Boole[Mod[n, k] == 0], Boole[m == 0]]; Array[a, 105] (* Jean-François Alcover, Jul 29 2015, after Reinhard Zumkeller *)
A083206(n) = { my(s=sigma(n),p=1); if(s%2 || s < 2*n, 0, fordiv(n, d, p *= ('x^d + 'x^-d)); (polcoeff(p, 0)/2)); }; \\ Antti Karttunen, Dec 02 2024, after Ilya Gutkovskiy
a(6) = 1 + 2 + 3 - 6 = 0.
A103977 := proc(n) local divs,a,acandid,filt,i,p,sigs ; divs := convert(numtheory[divisors](n),list) ; a := add(i,i=divs) ; for sigs from 0 to 2^nops(divs)-1 do filt := convert(sigs,base,2) ; while nops(filt) < nops(divs) do filt := [op(filt), 0] ; od ; acandid := 0 ; for p from 0 to nops(divs)-1 do if op(p+1,filt) = 0 then acandid := acandid-op(p+1,divs) ; else acandid := acandid+op(p+1,divs) ; fi ; od: acandid := abs(acandid) ; if acandid < a then a := acandid ; fi ; od: RETURN(a) ; end: seq(A103977(n),n=1..80) ; # R. J. Mathar, Nov 27 2007 # second Maple program: a:= proc(n) option remember; local l, b; l, b:= [numtheory[divisors](n)[]], proc(s, i) option remember; `if`(i<1, s, min(b(s+l[i], i-1), b(abs(s-l[i]), i-1))) end: b(0, nops(l)) end: seq(a(n), n=1..80); # Alois P. Heinz, Dec 05 2024
a[n_] := Module[{d = Divisors[n], c, p, m}, c = CoefficientList[Product[1 + x^i, {i, d}], x]; p = -1 + Position[c, ?(# > 0 &)] // Flatten; m = Length[p]; If[OddQ[m], If[(d = p[[(m + 1)/2]] - p[[(m - 1)/2]]) == 1, 0, d], p[[m/2 + 1]] - p[[m/2]]]]; Array[a, 100] (* _Amiram Eldar, Dec 11 2019 *)
nonzerocoefpositions(p) = { my(v=Vec(p), lista=List([])); for(i=1,#v,if(v[i], listput(lista,i))); Vec(lista); }; \\ Doesn't need to be 0-based, as we use their differences only. A103977(n) = { my(p=1); fordiv(n, d, p *= (1 + 'x^d)); my(plist=nonzerocoefpositions(p), m = #plist, d); if(!(m%2), plist[1+(m/2)]-plist[m/2], d = plist[(m+1)/2]-plist[(m-1)/2]; if(1==d,0,d)); }; \\ Antti Karttunen, Dec 03 2024, after Mathematica-program by Amiram Eldar
T(8,1) = 1: 12345678. T(8,2) = 7: 12348|567, 12357|468, 12456|378, 1278|3456, 1368|2457, 1458|2367, 1467|2358. T(8,3) = 3: 1236|48|57, 138|246|57, 156|237|48. T(8,4) = 1: 18|27|36|45. T(9,3) = 9: 12345|69|78, 1239|456|78, 1248|357|69, 1257|348|69, 1347|258|69, 1356|249|78, 159|2346|78, 168|249|357, 159|267|348. Triangle T(n,k) begins: 00 : 1; 01 : 0, 1; 02 : 0, 1; 03 : 0, 1, 1; 04 : 0, 1, 1; 05 : 0, 1, 0, 1; 06 : 0, 1, 0, 1; 07 : 0, 1, 4, 0, 1; 08 : 0, 1, 7, 3, 1; 09 : 0, 1, 0, 9, 0, 1; 10 : 0, 1, 0, 0, 0, 1; 11 : 0, 1, 35, 43, 0, 0, 1; 12 : 0, 1, 62, 102, 0, 0, 1; 13 : 0, 1, 0, 0, 0, 0, 0, 1; 14 : 0, 1, 0, 595, 0, 68, 0, 1; 15 : 0, 1, 361, 1480, 871, 187, 17, 0, 1;
Needs["Combinatorica`"]; T[n_, k_] := Count[(Equal @@ (Total /@ #)&) /@ KSetPartitions[n, k], True]; Table[row = Table[T[n, k], {k, 0, Ceiling[n/2]}]; Print[n, " ", row]; row, {n, 0, 12}] // Flatten (* Jean-François Alcover, Jan 20 2017 *)
x = 3: for n = 2 there are 2 possibilities: 1*3*9=27 and 1/3*9=3. For n = 4 there are 9 possibilities: 1*3*9*27*81 1/3*9*27*81 1*3/9*27*81 1/3/9*27*81 1*3*9/27*81 1*3*9*27/81 1/3*9/27*81 1/3*9*27/81 1*3/9/27*81
Table[Length[Select[Subsets[Range[n]],Plus@@Complement[Range[n],#]>=Plus@@#&]],{n,0,10}] (* Gus Wiseman, Jul 04 2019 *)
a(1)=1 since there is only one way of partitioning {1,2,3,4} into two sets of equal sum, namely {1,4}, {2,3}.
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, 4*n-1): seq(a(n), n=0..30); # Alois P. Heinz, Oct 30 2011
b[n_, i_] := b[n, i] = Module[{m = i*(i+1)/2}, If[n > m, 0, If[n == m, 1, b[Abs[n-i], i-1] + b[n+i, i-1]]]]; a[n_] := b[4*n, 4*n-1]; Table[a[n], {n, 0, 30}] (* Jean-François Alcover, Sep 26 2013, translated from Alois P. Heinz's Maple program *)
For n=8 we have 84/75/6321, 84/732/651 and 831/75/642 so a(8)=3.
A112972:= n-> coeff(coeff(mul((x^(-2*k)+x^k*(y^k+y^(-k))) , k=1..n), x, 0), y, 0)/6: seq(A112972(n), n=1..20); # second Maple program: b:= proc() option remember; local i, j, t; `if`(args[1]=0, `if`(nargs=2, 1, b(args[t] $t=2..nargs)), add( `if`(args[j] -args[nargs]<0, 0, b(sort([seq(args[i]- `if`(i=j, args[nargs], 0), i=1..nargs-1)])[], args[nargs]-1)), j=1..nargs-1)) end: a:= n-> (m-> `if`(irem(m, 3)=0, b((m/3)$3, n)/6, 0))(n*(n+1)/2): seq(a(n), n=1..42); # Alois P. Heinz, Sep 03 2009
b[args_List] := b[args] = Module[{nargs = Length[args]}, If[args[[1]] == 0, If[nargs == 2, 1, b[args // Rest]], Sum[If[args[[j]] - Last[args] < 0, 0, b[Append[Sort[Flatten[Table[args[[i]] - If[i == j, Last[args], 0], {i, 1, nargs-1}]]], Last[args]-1]]], {j, 1, nargs-1}]]]; a[n_] := If[Mod[#, 3] == 0, b[{#/3, #/3, #/3, n}]/6, 0]&[n(n+1)/2]; Array[a, 42] (* Jean-François Alcover, Oct 30 2020, after Alois P. Heinz *)
Solutions for n = 7: -------------------------- 1 +2 +3 +4 +5 +6 +7 = 28. 1 +2 +3 +4 +5 +6 -7 = 14. 1 +2 -3 +4 -5 -6 +7 = 0. 1 +2 -3 +4 -5 -6 -7 = -14. 1 +2 -3 -4 +5 +6 +7 = 14. 1 +2 -3 -4 +5 +6 -7 = 0. 1 -2 +3 +4 -5 +6 +7 = 14. 1 -2 +3 +4 -5 +6 -7 = 0. 1 -2 -3 -4 -5 +6 +7 = 0. 1 -2 -3 -4 -5 +6 -7 = -14.
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, m-i])) end: a:= n-> b(0, n-1, n): seq(a(n), n=1..60); # Alois P. Heinz, Mar 01 2018
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, m - i}}]]; a[n_] := b[0, n - 1, n]; Array[a, 60] (* Jean-François Alcover, Apr 29 2020, after Alois P. Heinz *)
def A(n) ary = [1] + Array.new(n - 1, 0) (1..n).each{|i| i1 = 2 * i a = ary.clone (0..n - 1).each{|j| a[(j + i1) % n] += ary[j]} ary = a } ary[(n * (n + 1) / 2) % n] / 2 end def A300190(n) (1..n).map{|i| A(i)} end p A300190(100)
Comments