Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #25 Sep 02 2024 13:03:25
%S 0,1,3,13,90,726,7089,78369,973404,13377156,201443165,3297443264,
%T 58304208767,1107693755122
%N Consider the array T(r,c), the number of c-almost primes less than or equal to r^c. This is the diagonal T(r,r-1).
%t 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 *)
%t Do[ Print@ AlmostPrimePi[n, (n + 1)^n], {n, 11}]
%o (Python)
%o from math import isqrt, prod
%o from sympy import primerange, integer_nthroot, primepi
%o def A116434(n):
%o def almostprimepi(n, k):
%o 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)))
%o 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))
%o return almostprimepi((n+1)**n,n) # _Chai Wah Wu_, Sep 02 2024
%Y Cf. A116433, A116435.
%K hard,more,nonn
%O 1,3
%A _Paul D. Hanna_ and _Robert G. Wilson v_, Feb 15 2006
%E Name rephrased by _R. J. Mathar_, Jun 20 2021
%E a(13)-a(14) from _Max Alekseyev_, Oct 12 2023