login
A078845
Where 7^n occurs in n-almost-primes, starting at a(0)=1.
14
1, 4, 17, 82, 385, 1688, 7089, 28893, 115180, 450906, 1740244, 6640747, 25115604, 94312569, 352110321, 1308256678, 4841115048, 17852264639, 65636109307, 240689877440, 880582139867
OFFSET
0,2
COMMENTS
A k-almost-prime is a positive integer that has exactly k prime factors, counted with multiplicity.
LINKS
Eric Weisstein's World of Mathematics, Almost Prime.
EXAMPLE
a(2) = 17 since 7^2 is the 17th 2-almost-prime: {4,6,9,10,14,15,21,22,25,26,33,34,35,38,39,46,49,...}.
MATHEMATICA
l = Table[0, {30}]; e = 0; Do[f = Plus @@ Last /@ FactorInteger[n]; l[[f+1]]++; If[n == 7^e, Print[l[[f+1]]]; e++ ], {n, 1, 7^10}] (* Ryan Propper, Aug 08 2005 *)
AlmostPrimePi[k_Integer /; k > 1, n_] := Module[{a, i}, a[0] = 1; 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 *)
Table[ AlmostPrimePi[n, 7^n], {n, 2, 15}] (* Robert G. Wilson v, Feb 09 2006 *)
PROG
(Python)
from math import isqrt, prod
from sympy import primerange, integer_nthroot, primepi
def almostprimepi(n, k):
if k==0: return int(n>=1)
def g(x, a, b, c, m): yield from (((d, ) for d in enumerate(primerange(b, isqrt(x//c)+1), a)) if m==2 else (((a2, b2), )+d for a2, b2 in enumerate(primerange(b, integer_nthroot(x//c, m)[0]+1), a) for d in g(x, a2, b2, c*b2, m-1)))
return int(sum(primepi(n//prod(c[1] for c in a))-a[-1][0] for a in g(n, 0, 1, 1, k)) if k>1 else primepi(n))
def A078845(n): return almostprimepi(7**n, n) if n else 1 # Chai Wah Wu, Oct 02 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Benoit Cloitre and Paul D. Hanna, Dec 10 2002
EXTENSIONS
a(7)-a(10) from Ryan Propper, Aug 08 2005
a(11)-a(15) from Robert G. Wilson v, Feb 09 2006
a(16)-a(20) from Donovan Johnson, Sep 27 2010
STATUS
approved