login
Number of compositions (ordered partitions) of n into distinct odd primes.
3

%I #12 Nov 09 2020 02:57:08

%S 1,0,0,1,0,1,0,1,2,0,2,1,2,1,2,6,4,1,4,7,4,12,4,13,6,12,28,18,28,19,6,

%T 25,52,24,54,30,56,31,98,156,102,37,104,157,150,276,150,175,154,288,

%U 200,528,246,307,226,666,990,780,1038,679,348,799,1828,1272,1162,1164

%N Number of compositions (ordered partitions) of n into distinct odd primes.

%H Alois P. Heinz, <a href="/A331981/b331981.txt">Table of n, a(n) for n = 0..10000</a>

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

%e a(16) = 4 because we have [13, 3], [11, 5], [5, 11] and [3, 13].

%p s:= proc(n) option remember; `if`(n<1, 0, ithprime(n+1)+s(n-1)) end:

%p b:= proc(n, i, t) option remember; `if`(s(i)<n, 0, `if`(n=0, t!, (p

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

%p end:

%p a:= n-> b(n, numtheory[pi](n), 0):

%p seq(a(n), n=0..72); # _Alois P. Heinz_, Feb 03 2020

%t s[n_] := s[n] = If[n < 1, 0, Prime[n + 1] + s[n - 1]];

%t b[n_, i_, t_] := b[n, i, t] = If[s[i] < n, 0, If[n == 0, t!, If[# > n, 0, b[n - #, i - 1, t + 1]]&[Prime[i + 1]] + b[n, i - 1, t]]];

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

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

%Y Cf. A002124, A023360, A024939, A065091, A099773, A219107, A331926, A331982.

%K nonn

%O 0,9

%A _Ilya Gutkovskiy_, Feb 03 2020