OFFSET
1,1
LINKS
Robert G. Wilson v, Table of n, a(n) for n=1..1000
FORMULA
EXAMPLE
a(1) = prime(4almostprime(1)) - 4almostprime(prime(1)) = 53 - 24 = 29.
a(2) = prime(4almostprime(2)) - 4almostprime(prime(2)) = 89 - 36 = 53.
a(3) = prime(4almostprime(3)) - 4almostprime(prime(3)) = 151 - 54 = 97.
It is mere coincidence that the first 4 values are all primes.
MATHEMATICA
FourAlmostPrimePi[n_] := Sum[PrimePi[n/(Prime@i*Prime@j*Prime@k)] - k + 1, {i, PrimePi[n^(1/4)]}, {j, i, PrimePi[(n/Prime@i)^(1/3)]}, {k, j, PrimePi@ Sqrt[n/(Prime@i*Prime@j)]}];
FourAlmostPrime[n_] := Block[{e = Floor[Log[2, n] + 1], a, b}, a = 2^e; Do[b = 2^p; While[ FourAlmostPrimePi@a < n, a = a + b]; a = a - b/2, {p, e, 0, -1}]; a + b/2];
Table[ Prime@ FourAlmostPrime@ n - FourAlmostPrime@ Prime@ n, {n, 52}]
PROG
(Python)
from math import isqrt
from sympy import primepi, primerange, integer_nthroot, prime
def A124284(n):
def f(x): return int(x-sum(primepi(x//(k*m*r))-c for a, k in enumerate(primerange(integer_nthroot(x, 4)[0]+1)) for b, m in enumerate(primerange(k, integer_nthroot(x//k, 3)[0]+1), a) for c, r in enumerate(primerange(m, isqrt(x//(k*m))+1), b)))
m, k = n, f(n)+n
while m != k:
m, k = k, f(k)+n
r, k = (p:=prime(n)), f(p)+p
while r != k:
r, k = k, f(k)+p
return prime(m)-r # Chai Wah Wu, Aug 17 2024
CROSSREFS
Cf. Primes indexed by 4-almost primes = A124282. 4-almost primes indexed by primes = A124283. Primes indexed by 3-almost primes = A124268. 3-almost primes indexed by primes = A124269. prime(3almostprime(n)) - 3almostprime(prime(n)) = A124270. See also A106349 Primes indexed by semiprimes. See also A106350 Semiprimes indexed by primes. See also A122824 Prime(semiprime(n)) - semiprime(prime(n)).
KEYWORD
easy,nonn
AUTHOR
Jonathan Vos Post, Oct 24 2006
EXTENSIONS
More terms from Robert G. Wilson v, Aug 31 2007
STATUS
approved