This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A078843 #42 Feb 16 2025 08:32:48 %S A078843 1,2,3,5,8,14,23,39,64,103,169,269,427,676,1065,1669,2628,4104,6414, %T A078843 10023,15608,24281,37733,58503,90616,140187,216625,334527,516126, %U A078843 795632,1225641,1886570,2901796,4460359,6851532,10518476,16138642,24748319 %N A078843 Where 3^n occurs in n-almost primes, starting at a(0)=1. %H A078843 Max Alekseyev, <a href="/A078843/b078843.txt">Table of n, a(n) for n = 0..50</a> %H A078843 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/AlmostPrime.html">Almost Prime</a>. %F A078843 a(n) = a(n-1) + appi3(n-k, floor(3^n/2^k)), where k = ceiling(n*c) with c = log(5/3)/log(5/2) = 0.55749295065024006729857073190835923443... and appi3(k,n) is the number of k-almost primes not divisible by 3 and not exceeding n. - _Max Alekseyev_, Jan 06 2008 %e A078843 a(3) = 5 since 3^3 is the 5th 3-almost-prime: 8,12,18,20,27,....., A014612. %t A078843 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 *) %t A078843 Table[ AlmostPrimePi[n, 3^n], {n, 2, 37}] (* _Robert G. Wilson v_, Feb 09 2006 *) %o A078843 (PARI) a(n)=sum(i=1,3^n,if(bigomega(i)-n,0,1)) %o A078843 (PARI) %o A078843 { appi(k,n,m=2) = local(r=0); %o A078843 if(k==0,return(1)); %o A078843 if(k==1,return(primepi(n))); %o A078843 forprime(p=m, floor(sqrtn(n,k)+1e-20), %o A078843 r+=appi(k-1,n\p,p)-(k==2)*(primepi(p)-1)); %o A078843 r } %o A078843 { appi3(k,n) = appi(k,n) - if(k>=1,appi(k-1,n\3)) } %o A078843 a=1; for(n=1,50, k=ceil(n*log(5/3)/log(5/2)); a+=appi3(n-k,3^n\2^k); print1(a,", ")) %o A078843 \\ _Max Alekseyev_, Jan 06 2008 %o A078843 (Python) %o A078843 from math import isqrt, prod %o A078843 from sympy import primerange, integer_nthroot, primepi %o A078843 def A078843(n): %o A078843 def almostprimepi(n,k): %o A078843 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 A078843 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 A078843 return almostprimepi(3**n,n) if n else 1 # _Chai Wah Wu_, Sep 01 2024 %Y A078843 Cf. A078840, A078841, A078842, A078844, A078845, A078846. %K A078843 nonn %O A078843 0,2 %A A078843 _Benoit Cloitre_ and _Paul D. Hanna_, Dec 10 2002 %E A078843 a(14)-a(37) from _Robert G. Wilson v_, Feb 09 2006