A115588 Number of distinct prime numbers necessary to represent a natural number n > 1.
1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 3, 1, 2, 2, 2, 2, 2, 1, 2, 2, 3, 1, 3, 1, 2, 3, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 3, 2, 2, 1, 3, 1, 2, 3, 2, 2, 3, 1, 2, 2, 3, 1, 2, 1, 2, 3, 2, 2, 3, 1, 2, 2, 2, 1, 3, 2, 2, 2, 3, 1, 3, 2, 2, 2, 2, 2, 3, 1, 2, 3, 2, 1, 3, 1, 3, 3, 2
Offset: 2
Keywords
Examples
a(4)=1, since 4=2^2 and the only prime used was 2. a(30)=3 because 30=2*3*5 and three primes were necessary. a(65536)=1, since 65536=2^16=2^(2^4)=2^(2^(2^2)) and, again, only one prime was needed. a(1) would be undefined, so it is not included.
Links
- Alois P. Heinz, Table of n, a(n) for n = 2..10000
Programs
-
Maple
b:= n-> `if`(n=1, {}, {seq([i[1], b(i[2])[]][], i=ifactors(n)[2])}): a:= n-> nops(b(n)): seq(a(n), n=1..200); # Alois P. Heinz, Apr 27 2012
-
Mathematica
A115588[n_] := Length[Union[NestWhile[DeleteCases[Flatten[FactorInteger[#]], 1] &, {n}, AnyTrue[#, CompositeQ] &]]]; Array[A115588, 100, 2] (* Paolo Xausa, Feb 24 2025 *)
-
PARI
listf(f, list) = {for (k=1, #f~, listput(list, f[k,1]); if (isprime(f[k,2]), listput(list, f[k,2]), if (f[k,2] > 1, my(vexp = Vec(listf(factor(f[k,2]), list))); for (i=1, #vexp, listput(list, vexp[i]););););); list;} a(n) = {my(f=factor(n), list=List()); #select(isprime, Set(Vec(listf(f, list))));} \\ Michel Marcus, Dec 02 2020
Comments