cp's OEIS Frontend

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.

A078845 Where 7^n occurs in n-almost-primes, starting at a(0)=1.

This page as a plain text file.
%I A078845 #29 Feb 16 2025 08:32:48
%S A078845 1,4,17,82,385,1688,7089,28893,115180,450906,1740244,6640747,25115604,
%T A078845 94312569,352110321,1308256678,4841115048,17852264639,65636109307,
%U A078845 240689877440,880582139867
%N A078845 Where 7^n occurs in n-almost-primes, starting at a(0)=1.
%C A078845 A k-almost-prime is a positive integer that has exactly k prime factors, counted with multiplicity.
%H A078845 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/AlmostPrime.html">Almost Prime.</a>
%e A078845 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,...}.
%t A078845 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 *)
%t A078845 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 A078845 Table[ AlmostPrimePi[n, 7^n], {n, 2, 15}] (* _Robert G. Wilson v_, Feb 09 2006 *)
%o A078845 (Python)
%o A078845 from math import isqrt, prod
%o A078845 from sympy import primerange, integer_nthroot, primepi
%o A078845 def almostprimepi(n,k):
%o A078845     if k==0: return int(n>=1)
%o A078845     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 A078845     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 A078845 def A078845(n): return almostprimepi(7**n,n) if n else 1 # _Chai Wah Wu_, Oct 02 2024
%Y A078845 Cf. A078840, A078841, A078842, A078843, A078844, A078846.
%K A078845 nonn
%O A078845 0,2
%A A078845 _Benoit Cloitre_ and _Paul D. Hanna_, Dec 10 2002
%E A078845 a(7)-a(10) from _Ryan Propper_, Aug 08 2005
%E A078845 a(11)-a(15) from _Robert G. Wilson v_, Feb 09 2006
%E A078845 a(16)-a(20) from _Donovan Johnson_, Sep 27 2010