A129852 Nondescending wiggly sums: number of sums adding to n in which terms alternately do not decrease and do not increase.
1, 1, 2, 3, 5, 9, 15, 26, 45, 79, 135, 236, 408, 710, 1230, 2137, 3705, 6436, 11165, 19384, 33637, 58391, 101336, 175896, 305284, 529884, 919683, 1596277, 2770576, 4808811, 8346446, 14486644, 25143896, 43641363, 75746646, 131470683, 228188723, 396058740, 687424365, 1193136983, 2070883422
Offset: 0
Keywords
Examples
From _Joerg Arndt_, May 21 2013: (Start) The a(6)=15 such compositions are 01: [ 1 1 1 1 1 1 ] 02: [ 1 1 1 2 1 ] 03: [ 1 1 1 3 ] 04: [ 1 2 1 1 1 ] 05: [ 1 2 1 2 ] 06: [ 1 3 1 1 ] 07: [ 1 3 2 ] 08: [ 1 4 1 ] 09: [ 1 5 ] 10: [ 2 2 1 1 ] 11: [ 2 2 2 ] 12: [ 2 3 1 ] 13: [ 2 4 ] 14: [ 3 3 ] 15: [ 6 ] (End)
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..2000
Programs
-
Maple
A129852rec := proc(part,n) local asum,a,k ; asum := add(i,i=part) ; if asum > n then RETURN(0) ; elif asum = n then RETURN(1) ; else a := 0 ; if nops(part) mod 2 = 1 then for k from op(-1,part) to n-asum do a := a+A129852rec([op(part),k],n) ; od: else for k from 1 to min(op(-1,part),n-asum) do a := a+A129852rec([op(part),k],n) ; od: fi ; RETURN(a) ; fi ; end: A129852 := proc(n) local a,a1 ; a := 0 ; for a1 from 1 to n do a := a+A129852rec([a1],n) ; od: RETURN(a) ; end: seq(A129852(n),n=1..20) ; # R. J. Mathar, Oct 31 2007 # second Maple program: b:= proc(n, l, t) option remember; `if`(n=0, 1, add( b(n-j, j, not t), j=`if`(t, l..n, 1..min(n, l)))) end: a:= n-> b(n$2, false): seq(a(n), n=0..40); # Alois P. Heinz, May 23 2023
-
Mathematica
b[n_, l_, t_] := b[n, l, t] = If[n == 0, 1, Sum[b[n-j, j, !t], {j, If[t, Range[l, n], Range[Min[n, l]]]}]]; a[n_] := b[n, n, False]; Table[a[n], {n, 0, 40}] (* Jean-François Alcover, May 23 2023, after Alois P. Heinz *)
Extensions
More terms from R. J. Mathar, Oct 31 2007
More terms from Joerg Arndt, May 21 2013
a(0)=1 prepended by Alois P. Heinz, May 23 2023