login
Number of compositions (ordered partitions) of n into distinct triangular numbers.
14

%I #11 Apr 27 2020 05:55:13

%S 1,1,0,1,2,0,1,2,0,2,7,2,0,2,6,1,4,6,2,12,24,3,8,0,8,32,6,2,13,26,6,

%T 34,36,0,32,150,3,20,50,14,54,126,32,32,12,55,160,78,122,44,174,4,72,

%U 294,36,201,896,128,62,180,176,164,198,852,110,320,159,212,414

%N Number of compositions (ordered partitions) of n into distinct triangular numbers.

%H Alois P. Heinz, <a href="/A331843/b331843.txt">Table of n, a(n) for n = 0..20000</a>

%H <a href="/index/Com#comp">Index entries for sequences related to compositions</a>

%e a(10) = 7 because we have [10], [6, 3, 1], [6, 1, 3], [3, 6, 1], [3, 1, 6], [1, 6, 3] and [1, 3, 6].

%p h:= proc(n) option remember; `if`(n<1, 0,

%p `if`(issqr(8*n+1), 1+h(n-1), h(n-1)))

%p end:

%p b:= proc(n, i, p) option remember; (t->

%p `if`(t*(i+2)/3<n, 0, `if`(n=0, p!, b(n, i-1, p)+

%p `if`(t>n, 0, b(n-t, i-1, p+1)))))((i*(i+1)/2))

%p end:

%p a:= n-> b(n, h(n), 0):

%p seq(a(n), n=0..73); # _Alois P. Heinz_, Jan 31 2020

%t h[n_] := h[n] = If[n<1, 0, If[IntegerQ @ Sqrt[8n+1], 1 + h[n-1], h[n-1]]];

%t b[n_, i_, p_] := b[n, i, p] = Function[t, If[t (i + 2)/3 < n, 0, If[n == 0, p!, b[n, i-1, p] + If[t>n, 0, b[n - t, i - 1, p + 1]]]]][(i(i + 1)/2)];

%t a[n_] := b[n, h[n], 0];

%t a /@ Range[0, 73] (* _Jean-François Alcover_, Apr 27 2020, after _Alois P. Heinz_ *)

%Y Cf. A000217, A023361, A024940, A032020, A032021, A032022, A218396, A219107, A331844, A331845, A331846, A331847.

%K nonn

%O 0,5

%A _Ilya Gutkovskiy_, Jan 29 2020