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.

Previous Showing 41-50 of 144 results. Next

A078841 Main diagonal of the table of k-almost primes (A078840): a(n) = (n+1)-st integer that is an n-almost prime.

Original entry on oeis.org

1, 3, 9, 20, 54, 112, 240, 648, 1344, 2816, 5760, 12800, 26624, 62208, 129024, 270336, 552960, 1114112, 2293760, 4915200, 9961472, 20447232, 47775744, 96468992, 198180864, 411041792, 830472192, 1698693120, 3422552064, 7046430720
Offset: 0

Views

Author

Benoit Cloitre and Paul D. Hanna, Dec 10 2002

Keywords

Comments

A k-almost prime is a positive integer that has exactly k prime factors counted with multiplicity.

Examples

			a(0) = 1 since one is the multiplicative identity,
a(1) = 2nd 1-almost prime is the second prime number = A000040(2) = 3,
a(2) = 3rd 2-almost prime = 3rd semiprime = A001358(3) = 9 = {3*3}.
a(3) = 4th 3-almost prime = A014612(4) = 20 = {2*2*5}.
a(4) = 5th 4-almost prime = A014613(5) = 54 = {2*3*3*3},
a(5) = 6th 5-almost prime = A014614(6) = 112 = {2*2*2*2*7}, ....
		

Crossrefs

Programs

  • Mathematica
    f[n_] := Plus @@ Last /@ FactorInteger@n; t = Table[{}, {40}]; Do[a = f[n]; AppendTo[ t[[a]], n]; t[[a]] = Take[t[[a]], 10], {n, 2, 148*10^8}]; Table[ t[[n, n + 1]], {n, 30}] (* Robert G. Wilson v, Feb 11 2006 *)
    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 *)
    AlmostPrime[k_, n_] := Block[{e = Floor[ Log[2, n] + k], a, b}, a = 2^e; Do[b = 2^p; While[ AlmostPrimePi[k, a] < n, a = a + b]; a = a - b/2, {p, e, 0, -1}]; a + b/2]; AlmostPrime[1, 1] = 2; lst = {}; Do[ AppendTo[lst, AlmostPrime[n-1, n]], {n, 30}]; lst (* Robert G. Wilson v, Nov 13 2007 *)
  • Python
    from math import prod, isqrt
    from sympy import primerange, integer_nthroot, primepi
    def A078841(n):
        if n <= 1: return (n<<1)+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)))
        def f(x): return int(n+x-sum(primepi(x//prod(c[1] for c in a))-a[-1][0] for a in g(x,0,1,1,n)))
        kmin, kmax = 1,2
        while f(kmax) >= kmax:
            kmax <<= 1
        while True:
            kmid = kmax+kmin>>1
            if f(kmid) < kmid:
                kmax = kmid
            else:
                kmin = kmid
            if kmax-kmin <= 1:
                break
        return kmax # Chai Wah Wu, Aug 23 2024

Formula

Conjecture: Lim as n->inf. of a(n+1)/a(n) = 2. - Robert G. Wilson v, Nov 13 2007

Extensions

a(14)-a(29) from Robert G. Wilson v, Feb 11 2006

A114106 Number of 4-almost primes less than or equal to 10^n.

Original entry on oeis.org

0, 0, 12, 149, 1712, 18744, 198062, 2050696, 20959322, 212385942, 2139236881, 21454599814, 214499908019, 2139634739326, 21306682904040, 211905511283590, 2105504493045818, 20905484578206982, 207458897819329031, 2057931819347474462
Offset: 0

Views

Author

Robert G. Wilson v, Feb 07 2006

Keywords

Examples

			There are 12 primes with four almost primes up to 100: 16, 24, 36, 40, 54, 56, 60, 81, 84, 88, 90 and 100, so a(2) = 12.
		

Crossrefs

Programs

  • 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)]}]; Table[ FourAlmostPrimePi[n], {n, 0, 13}]
  • Python
    from math import isqrt
    from sympy import primepi, primerange, integer_nthroot
    def A114106(n): return sum(primepi(10**n//(k*m*r))-c for a,k in enumerate(primerange(integer_nthroot(10**n,4)[0]+1)) for b,m in enumerate(primerange(k,integer_nthroot(10**n//k,3)[0]+1),a) for c,r in enumerate(primerange(m,isqrt(10**n//(k*m))+1),b)) # Chai Wah Wu, Aug 17 2024

Extensions

a(14) from Robert G. Wilson v, Jan 07 2007
a(15)-a(17) from Henri Lifchitz, Jul 21 2015
a(18)-a(19) from Henri Lifchitz, Feb 02 2025

A101695 a(n) = n-th n-almost prime.

Original entry on oeis.org

2, 6, 18, 40, 108, 224, 480, 1296, 2688, 5632, 11520, 25600, 53248, 124416, 258048, 540672, 1105920, 2228224, 4587520, 9830400, 19922944, 40894464, 95551488, 192937984, 396361728, 822083584, 1660944384, 3397386240, 6845104128
Offset: 1

Views

Author

Jonathan Vos Post, Dec 12 2004

Keywords

Comments

A k-almost-prime is a positive integer that has exactly k prime factors, counted with multiplicity.
This is the diagonalization of the set of sequences {j-almost prime(k)}. The cumulative sums of this sequence are in A101696. This is the diagonal just below A078841.

Examples

			a(1) = first 1-almost prime = first prime = A000040(1) = 2.
a(2) = 2nd 2-almost prime = 2nd semiprime = A001358(2) = 6.
a(3) = 3rd 3-almost prime = A014612(3) = 18.
a(4) = 4th 4-almost prime = A014613(4) = 40.
a(5) = 5th 5-almost prime = A014614(5) = 108.
		

Crossrefs

Programs

  • Maple
    A101695 := proc(n)
        local s,a ;
        s := 0 ;
        for a from 2^n do
            if numtheory[bigomega](a) = n then
                s := s+1 ;
                if s = n then
                    return a;
                end if;
            end if;
        end do:
    end proc: # R. J. Mathar, Aug 09 2012
  • Mathematica
    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 *)
    AlmostPrime[k_, n_] := Block[{e = Floor[ Log[2, n] + k], a, b}, a = 2^e; Do[b = 2^p; While[ AlmostPrimePi[k, a] < n, a = a + b]; a = a - b/2, {p, e, 0, -1}]; a + b/2]; AlmostPrime[1, 1] = 2; lst = {}; Do[ AppendTo[lst, AlmostPrime[n, n]], {n, 30}]; lst (* Robert G. Wilson v, Oct 07 2007 *)
  • Python
    from math import prod, isqrt
    from sympy import primerange, primepi, integer_nthroot
    def A101695(n):
        if n == 1: return 2
        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)))
        def f(x): return int(n-1+x-sum(primepi(x//prod(c[1] for c in a))-a[-1][0] for a in g(x,0,1,1,n)))
        kmin, kmax = 1,2
        while f(kmax) >= kmax:
            kmax <<= 1
        while True:
            kmid = kmax+kmin>>1
            if f(kmid) < kmid:
                kmax = kmid
            else:
                kmin = kmid
            if kmax-kmin <= 1:
                break
        return kmax # Chai Wah Wu, Aug 23 2024

Formula

Conjecture: lim_{ n->inf.} a(n+1)/a(n) = 2. - Robert G. Wilson v, Oct 07 2007, Nov 13 2007
Stronger conjecture: a(n)/(n * 2^n) is polylogarithmic in n. That is, there exist real numbers b < c such that (log n)^b < a(n)/(n * 2^n) < (log n)^c for large enough n. Probably b and c can be chosen close to 0. - Charles R Greathouse IV, Aug 28 2012

Extensions

a(21)-a(30) from Robert G. Wilson v, Feb 11 2006
a(12) corrected by N. J. A. Sloane, Nov 23 2007

A058933 Let k be bigomega(n) (i.e., n is a k-almost-prime). a(n) = number of k-almost-primes <= n.

Original entry on oeis.org

1, 1, 2, 1, 3, 2, 4, 1, 3, 4, 5, 2, 6, 5, 6, 1, 7, 3, 8, 4, 7, 8, 9, 2, 9, 10, 5, 6, 10, 7, 11, 1, 11, 12, 13, 3, 12, 14, 15, 4, 13, 8, 14, 9, 10, 16, 15, 2, 17, 11, 18, 12, 16, 5, 19, 6, 20, 21, 17, 7, 18, 22, 13, 1, 23, 14, 19, 15, 24, 16, 20, 3, 21, 25, 17, 18, 26, 19, 22, 4, 8, 27, 23
Offset: 1

Views

Author

Naohiro Nomoto, Jan 11 2001

Keywords

Comments

Equivalently, the number of positive integers less than or equal to n with the same number of prime factors as n, counted with multiplicity. - Gus Wiseman, Dec 28 2018
There is a close relationship between a(n) and a(n^2). See A209934 for an exploratory quantification. - Peter Munn, Aug 04 2019

Examples

			3 is prime, so a(3)=2. 10 is 2-almost prime (semiprime), so a(10)=4.
From _Gus Wiseman_, Dec 28 2018: (Start)
Column n lists the a(n) positive integers less than or equal to n with the same number of prime factors as n, counted with multiplicity:
  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20
  ---------------------------------------------------------------------
  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20
        2     3  4  5     6  9   7   8   11  10  14      13  12  17  18
              2     3     4  6   5       7   9   10      11  8   13  12
                    2        4   3       5   6   9       7       11  8
                                 2       3   4   6       5       7
                                         2       4       3       5
                                                         2       3
                                                                 2
(End)
		

Crossrefs

Positions of 1's are A000079.
Equivalent sequence restricted to squarefree numbers: A340313.

Programs

  • Maple
    p:= proc() 0 end:
    a:= proc(n) option remember; local t;
          t:= numtheory[bigomega](n);
          p(t):= p(t)+1
        end:
    seq(a(n), n=1..100);  # Alois P. Heinz, Oct 09 2015
  • Mathematica
    p[] = 0; a[n] := a[n] = Module[{t}, t = PrimeOmega[n]; p[t] = p[t]+1]; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 24 2017, after Alois P. Heinz *)
  • PARI
    a(n) = my(k=bigomega(n)); sum(i=1, n, bigomega(i)==k); \\ Michel Marcus, Jun 27 2024
    
  • Python
    from math import prod, isqrt
    from sympy import isprime, primepi, primerange, integer_nthroot, primeomega
    def A058933(n):
        if n==1: return 1
        if isprime(n): return primepi(n)
        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,primeomega(n)))) # Chai Wah Wu, Aug 28 2024

Formula

Ordinal transform of A001222 (bigomega). - Franklin T. Adams-Watters, Aug 28 2006
If a(n) < a(3^A001222(2n)) = A078843(A001222(2n)) then a(2n) = a(n), otherwise a(2n) > a(n). - Peter Munn, Aug 05 2019

Extensions

Name edited by Peter Munn, Dec 30 2022

A074969 Numbers with six distinct prime divisors.

Original entry on oeis.org

30030, 39270, 43890, 46410, 51870, 53130, 60060, 62790, 66990, 67830, 71610, 72930, 78540, 79170, 81510, 82110, 84630, 85470, 87780, 90090, 91770, 92820, 94710, 98670, 99330, 101010, 102102, 103530, 103740, 106260, 106590, 108570
Offset: 1

Views

Author

Zak Seidov, Oct 04 2002

Keywords

Comments

The smallest number with six distinct prime divisors is the product of the first six primes, 2*3*5*7*11 = 30030.
The smallest number with seven distinct prime divisors is the product of the first seven primes, 2*3*5*7*11*13 = 390390.

Examples

			60060 is a term because 60060 = 2^2*3*5*7*11*13 with six distinct prime divisors 2, 3, 5, 7, 11, 13
87780 is a term because 87780 = 2^2*3*5*7*11*19 with six distinct prime divisors 2, 3, 5, 7, 11, 19.
		

Crossrefs

Programs

  • Mathematica
    Select[Range[0,5*8! ],Length[FactorInteger[ # ]]==6&] (* Vladimir Joseph Stephan Orlovsky, Apr 22 2010 *)
  • PARI
    is(n)=omega(n)==6 \\ Charles R Greathouse IV, Jun 19 2016
    
  • PARI
    A246655(lim)=my(v=List(primes([2,lim\=1]))); for(e=2,logint(lim,2), forprime(p=2,sqrtnint(lim,e), listput(v,p^e))); Set(v)
    list(lim,pr=6)=if(pr==1, return(A246655(lim))); my(v=List(),pr1=pr-1,mx=prod(i=1,pr1,prime(i))); forprime(p=prime(pr),lim\mx, my(u=list(lim\p,pr1)); for(i=1,#u,listput(v,p*u[i]))); Set(v) \\ Charles R Greathouse IV, Feb 03 2023

Formula

{n : A001221(n) = 6} . - R. J. Mathar, Jul 07 2012

A110227 4-almost primes p * q * r * s relatively prime to p + q + r + s.

Original entry on oeis.org

40, 54, 56, 88, 90, 104, 135, 136, 152, 184, 189, 198, 210, 225, 232, 248, 250, 294, 296, 297, 306, 328, 344, 350, 351, 376, 390, 414, 424, 441, 459, 462, 472, 488, 513, 522, 536, 546, 550, 568, 570, 584, 621, 632, 664, 686, 712, 714, 735, 738, 765, 776
Offset: 1

Views

Author

Jonathan Vos Post, Jul 16 2005

Keywords

Comments

p, q, r, s are not necessarily distinct. The converse to this is A110228: 4-almost primes p * q * r * s not relatively prime to p+q+r+s.

Examples

			104 is in this sequence because 104 = 2^3 * 13, which is relatively prime to 2 + 2 + 2 + 13 = 19, which is prime.
		

Crossrefs

Programs

  • PARI
    list(lim)=my(v=List()); forprime(p=2,lim\8, forprime(q=2,min(p,lim\4\p), my(pq=p*q); forprime(r=2,min(lim\pq\2,q), my(pqr=pq*r,t); forprime(s=2,min(lim\pqr,r), t=pqr*s; if(gcd(t,p+q+r+s)==1, listput(v,t)))))); Set(v) \\ Charles R Greathouse IV, Jan 31 2017

Extensions

Corrected and extended by Ray Chandler, Jul 20 2005

A110228 4-almost primes p * q * r * s not relatively prime to p + q + r + s.

Original entry on oeis.org

16, 24, 36, 60, 81, 84, 100, 126, 132, 140, 150, 156, 196, 204, 220, 228, 234, 260, 276, 308, 315, 330, 340, 342, 348, 364, 372, 375, 380, 444, 460, 476, 484, 490, 492, 495, 510, 516, 525, 532, 558, 564, 572, 580, 585, 620, 625, 636, 644, 650, 666, 676, 690
Offset: 1

Views

Author

Jonathan Vos Post, Jul 16 2005

Keywords

Comments

p, q, r, s are not necessarily distinct. The converse to this is A110227: 4-almost primes p * q * r * s which are relatively prime to p+q+r+s.

Examples

			84 is in this sequence because 84 = 2^2 * 3 * 7 and the sum of these prime factors is 2 + 2 + 3 + 7 = 14 = 2 * 7, which is a divisor of 84.
		

Crossrefs

Programs

  • PARI
    list(lim)=my(v=List()); forprime(p=2,lim\8, forprime(q=2,min(p,lim\4\p), my(pq=p*q); forprime(r=2,min(lim\pq\2,q), my(pqr=pq*r,t); forprime(s=2,min(lim\pqr,r), t=pqr*s; if(gcd(t,p+q+r+s)>1, listput(v,t)))))); Set(v) \\ Charles R Greathouse IV, Jan 31 2017

Extensions

Corrected and extended by Ray Chandler, Jul 20 2005

A120049 Number of 8-almost primes less than or equal to 10^n.

Original entry on oeis.org

0, 0, 0, 7, 105, 1418, 17572, 207207, 2367507, 26483012, 291646797, 3173159326, 34192782745, 365561221293, 3882841742380, 41015564702074, 431227959019552, 4515480975731045, 47115876816676830
Offset: 0

Views

Author

Robert G. Wilson v, Feb 07 2006

Keywords

Examples

			There are 7 eight-almost primes up to 1000: 256, 384, 576, 640, 864, 896 & 960.
		

Crossrefs

Programs

  • Mathematica
    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 *)
    Table[AlmostPrimePi[8, 10^n], {n, 12}]
  • Python
    from math import prod, isqrt
    from sympy import primerange, integer_nthroot, primepi
    def A120049(n):
        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(10**n//prod(c[1] for c in a))-a[-1][0] for a in g(10**n,0,1,1,8))) # Chai Wah Wu, Aug 23 2024

Extensions

a(13)-a(14) from Robert G. Wilson v, Jan 07 2007
Example corrected by Harvey P. Dale, Aug 13 2018
a(15)-a(18) from Henri Lifchitz, Mar 18 2025

A109018 Least number with exactly n prime factors counted with multiplicity which gives a different number with exactly n prime factors counted with multiplicity when digits are reversed.

Original entry on oeis.org

13, 15, 117, 126, 270, 2576, 8820, 16560, 21168, 46848, 295245, 441600, 846720, 4078080, 80663040, 40590720, 2173236480, 4011724800, 21122906112, 40915058688, 274148425728, 63769149440, 2707602702336, 6167442456576, 21586195906560, 29798871072768, 420127895977984, 631722992467968
Offset: 1

Views

Author

Jonathan Vos Post, Jun 16 2005

Keywords

Comments

An emirp ("prime" spelled backwards) is a prime whose (base 10) reversal is also prime, but which is not a palindromic prime. The first few are 13, 17, 31, 37, 71, 73, 79, 97, 107, 113, 149, 157, ... (A006567).
An emirpimes ("semiprime" spelled backwards) is a semiprime whose (base 10) reversal is a different semiprime. A list of the first emirpimeses (or "semirpimes") are 15, 26, 39, 49, 51, 58, 62, 85, 93, 94, 115, 122, 123, ... (A097393).
An "emirp tsomla-3" ("3-almost prime" spelled backwards) is the k=3 sequence of the series for which k=1 are emirps and k=2 are emirpimes, a list of these being A109023. The union of these for k=1 through k = 13 is A109019.
The primes correspond to the "1-almost prime" numbers 2, 3, 5, 7, 11, ... (A000040). The 2-almost prime numbers correspond to semiprimes 4, 6, 9, 10, 14, 15, 21, 22, ... (A001358).
The first few 3-almost primes are 8, 12, 18, 20, 27, 28, 30, 42, 44, 45, 50, 52, 63, 66, 68, 70, 75, 76, 78, 92, 98, 99, ... (A014612). The first few 4-almost primes are 16, 24, 36, 40, 54, 56, 60, 81, 84, 88, 90, 100, ... (A014613).
The first few 5-almost primes are 32, 48, 72, 80, ... (A014614).
The Mathematica code for this was written by Ray Chandler, who has coauthorship credit for this sequence.

Examples

			a(1) = 13 because 13 is the smallest "emirp" (prime which, digits reversed, becomes a different prime) since reverse(13) = 31 is prime.
a(2) = 15 because 15 is the smallest emirpimes ("semiprime" spelled backwards) as a semiprime whose (base 10) reversal is a different semiprime. The first such number is 15, since 15 reversed is 51 and both 15 and 51 are semiprimes (i.e. 15 = 3 * 5 and 51 = 3 * 17).
a(3) = 117 because 117 is the smallest "emirp tsomla-3" ("3-almost prime" spelled backwards) since 117 reversed is 711 and 117 = 3^2 * 13 and 711 = 3^2 * 79.
		

Crossrefs

Programs

  • Mathematica
    kAlmost[n_] := Plus @@ Last /@ FactorInteger@n; fQ[n_] := Block[{id = IntegerDigits@n, k = kAlmost@n}, If[id != Reverse@id && k == kAlmost@FromDigits@Reverse@id, k, -1]]; t = Table[0, {20}]; Do[ a = fQ@n; If[a < 20 && t[[a]] == 0, t[[a]] = n; Print[{a, n}]], {n, 10, 150000000}] (* Robert G. Wilson v, Jan 06 2008 *)
    Table[Select[Range[41*10^5],!PalindromeQ[#]&&PrimeOmega[#]==PrimeOmega[ IntegerReverse[ #]] ==n&][[1]],{n,14}] (* The program generates the first 14 terms of the sequence. *) (* Harvey P. Dale, Oct 15 2023 *)

Extensions

a(14)-a(16) from Robert G. Wilson v, Jan 06 2008
a(17)-a(24) from Donovan Johnson, Nov 17 2008
a(25)-a(28) from Michael S. Branicky, Jun 04 2024

A120047 Number of 6-almost primes less than or equal to 10^n.

Original entry on oeis.org

0, 0, 2, 37, 485, 5933, 68963, 774078, 8493366, 91683887, 977694273, 10327249593, 108264085934, 1128049914377, 11694704489580, 120734708167792, 1242063105505230, 12739510126065301, 130330025583399801
Offset: 0

Views

Author

Robert G. Wilson v, Feb 07 2006

Keywords

Examples

			There are 2 six-almost primes up to 100: 64 and 96, so a(2) = 2.
		

Crossrefs

Programs

  • Mathematica
    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 *)
    Table[AlmostPrimePi[6, 10^n], {n, 0, 13}]
  • 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 A120047(n): return almostprimepi(10**n,6) # Chai Wah Wu, Dec 09 2024

Extensions

a(14) from Robert G. Wilson v, Jan 07 2007
a(15)-a(18) from Henri Lifchitz, Feb 03 2025
Previous Showing 41-50 of 144 results. Next