login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Number of compositions (ordered partitions) of n into prime divisors of n.
3

%I #15 Apr 22 2021 04:45:12

%S 1,0,1,1,1,1,2,1,1,1,2,1,12,1,2,2,1,1,65,1,23,2,2,1,351,1,2,1,38,1,

%T 15778,1,1,2,2,2,10252,1,2,2,1601,1,302265,1,80,750,2,1,299426,1,

%U 13404,2,107,1,1618192,2,5031,2,2,1,707445067,1,2,2398,1,2,119762253,1,173,2,39614048,1,255418101,1,2,154603

%N Number of compositions (ordered partitions) of n into prime divisors of n.

%H Alois P. Heinz, <a href="/A284463/b284463.txt">Table of n, a(n) for n = 0..2000</a>

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

%F a(n) = [x^n] 1/(1 - Sum_{p|n, p prime} x^p).

%F a(n) = 1 if n is a prime power > 1.

%F a(n) = 2 if n is a squarefree semiprime.

%e a(6) = 2 because 6 has 4 divisors {1, 2, 3, 6} among which 2 are primes {2, 3} therefore we have [3, 3] and [2, 2, 2].

%p a:= proc(n) option remember; local b, l;

%p l, b:= numtheory[factorset](n),

%p proc(m) option remember; `if`(m=0, 1,

%p add(`if`(j>m, 0, b(m-j)), j=l))

%p end; b(n)

%p end:

%p seq(a(n), n=0..100); # _Alois P. Heinz_, Mar 28 2017

%t Table[d = Divisors[n]; Coefficient[Series[1/(1 - Sum[Boole[PrimeQ[d[[k]]]] x^d[[k]], {k, Length[d]}]), {x, 0, n}], x, n], {n, 0, 75}]

%o (Python)

%o from sympy import divisors, isprime

%o from sympy.core.cache import cacheit

%o @cacheit

%o def a(n):

%o l=[x for x in divisors(n) if isprime(x)]

%o @cacheit

%o def b(m): return 1 if m==0 else sum(b(m - j) for j in l if j <= m)

%o return b(n)

%o print([a(n) for n in range(101)]) # _Indranil Ghosh_, Aug 01 2017, after Maple code

%Y Cf. A000040, A014652, A023360, A066882, A100346.

%K nonn

%O 0,7

%A _Ilya Gutkovskiy_, Mar 27 2017