OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..10000
EXAMPLE
Let n=5. We have only two allowed compositions 2+3 = 3+2. So a(5) = 2.
For n=6, we have compositions 6 = 1+2+3 = 1+3+2 = 2+3+1 = 2+1+3 = 3+2+1 = 3+1+2. Thus a(6) = 7.
MAPLE
b:= proc(n, i) option remember; `if`(n=0, 1, `if`(i<0, 0,
expand(b(n, i-1)+`if`(3*3^i>n, 0, b(n-3*3^i, i-1)*x^2)
+add(`if`(j*3^i>n, 0, b(n-j*3^i, i-1))*x, j=1..2))))
end:
a:= n->(p->add(coeff(p, x, j)*j!, j=0..degree(p)))(b(n, ilog[3](n))):
seq(a(n), n=0..100); # Alois P. Heinz, Jan 15 2014
MATHEMATICA
b[n_, i_] := b[n, i] = If[n==0, 1, If[i<0, 0, Expand[b[n, i-1] + If[3^(i+1) > n, 0, b[n-3^(i+1), i-1]x^2] + Sum[If[3^i j > n, 0, b[n-3^i j, i-1]]x, {j, 1, 2}]]]];
a[n_] := With[{p = b[n, Log[3, n] // Floor]}, Sum[Coefficient[p, x, j] j!, {j, 0, Exponent[p, x]}]];
a /@ Range[0, 100] (* Jean-François Alcover, Nov 12 2020, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn,look
AUTHOR
Vladimir Shevelev and Peter J. C. Moses, Jan 15 2014
STATUS
approved