OFFSET
1,1
LINKS
Eric Weisstein's World of Mathematics, Almost Prime.
EXAMPLE
a(1) = Prime(1) + Semiprime(1) + 3AlmostPrime(1) = 2 + 4 + 8 = 14.
a(10) = Prime(10) + Semiprime(10) + 3AlmostPrime(10) = 29 + 26 + 45 = 100.
a(20) = Prime(20) + Semiprime(20) + 3AlmostPrime(20) = 71 + 57 + 92 = 220.
a(30) = Prime(30) + Semiprime(30) + 3AlmostPrime(30) = 113 + 87 + 125 = 325.
a(40) = Prime(40) + Semiprime(40) + 3AlmostPrime(40) = 173 + 121 + 71 = 465.
a(50) = Prime(50) + Semiprime(50) + 3AlmostPrime(50) = 229 + 146 + 212 = 587.
MATHEMATICA
AlmostPrimePi[k_Integer, n_] := Module[{a, i}, a[0] = 1; If[k == 1, PrimePi[n], Sum[PrimePi[n/Times @@ Prime[ Array[a, k - 1]]] - a[k - 1] + 1, Evaluate[ Sequence @@ Table[{a[i], a[i - 1], PrimePi[(n/Times @@ Prime[Array[a, i - 1]])^(1/(k - i + 1))]}, {i, k - 1}]] ]]]; (* Eric W. Weisstein, Feb 07 2006 *)
AlmostPrime[k_, n_] := Block[{e = Floor[Log[2, n]+k], a, b}, a = 2^e; Do[b = 2^p; While[ AlmostPrimePi[k, a] < n, a = a + b]; a = a - b/2, {p, e, 0, -1}]; a + b/2]; Table[ Sum[ AlmostPrime[k, n], {k, 3}], {n, 54}] (* Robert G. Wilson v, Feb 21 2006 *)
CROSSREFS
KEYWORD
easy,less,nonn
AUTHOR
Jonathan Vos Post, Feb 11 2006
EXTENSIONS
a(7) corrected by Georg Fischer, May 09 2024
STATUS
approved