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 A066265 #68 Feb 16 2025 08:32:45 %S A066265 0,3,34,299,2625,23378,210035,1904324,17427258,160788536,1493776443, %T A066265 13959990342,131126017178,1237088048653,11715902308080, %U A066265 111329817298881,1061057292827269,10139482913717352,97123037685177087,932300026230174178,8966605849641219022,86389956293761485464,833671466551239927908,8056846659984852885191 %N A066265 a(n) = number of semiprimes < 10^n. %C A066265 Apart from the first nonzero term the sequence is identical to A036352. - _Hugo Pfoertner_, Jul 22 2003 %H A066265 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/Semiprime.html">Semiprime</a> %H A066265 <a href="/index/Pri#primepop">Index entries for sequences related to numbers of primes in various ranges</a> %F A066265 (1/2)*( pi(10^(n/2)) + Sum_{i=1..pi(10^n)} pi( (10^n-1)/P_i) ) = Sum_{i=1..pi(sqrt(10^n))} pi( (10^n-1)/P_i ) - binomial( pi(sqrt(10^n)), 2). - _Robert G. Wilson v_, May 16 2005 %e A066265 Below 10 there are three semiprimes: 4 (2*2), 6 (2*3) and 9 (3*3). %t A066265 f[n_] := Sum[ PrimePi[(10^n - 1)/Prime[i]], {i, PrimePi[ Sqrt[10^n]]}] - Binomial[ PrimePi[ Sqrt[10^n]], 2]; Do[ Print[ f[n]], {n, 0, 14}] (* _Robert G. Wilson v_, May 16 2005 *) %t A066265 SemiPrimePi[n_] := Sum[ PrimePi[n/Prime@ i] - i + 1, {i, PrimePi@ Sqrt@ n}]; Array[ SemiPrimePi[10^# - 1] &, 14, 0] (* _Robert G. Wilson v_, Jan 21 2015 *) %o A066265 (PARI) a(n)=my(s);forprime(p=2,sqrt(10^n),s+=primepi((10^n-1)\p)); s-binomial(primepi(sqrt(10^n)),2) \\ _Charles R Greathouse IV_, Apr 23 2012 %o A066265 (Perl) use Math::Prime::Util qw/:all/; use integer; sub countsp { my($k,$sum,$pc)=($_[0]-1,0,1); prime_precalc(60_000_000); forprimes { $sum += prime_count($k/$_) + 1 - $pc++; } int(sqrt($k)); $sum; } foreach my $n (0..16) { say "$n: ", countsp(10**$n); } # _Dana Jacobsen_, May 11 2014 %o A066265 (Python) %o A066265 from math import isqrt %o A066265 from sympy import primepi, primerange %o A066265 def A066265(n): return int((-(t:=primepi(s:=isqrt(m:=10**n)))*(t-1)>>1)+sum(primepi(m//k) for k in primerange(1, s+1))) if n>1 else 3*n # _Chai Wah Wu_, Aug 16 2024 %Y A066265 Cf. A001358, A064911, A072000, A036352 (identical starting from a(2)), A220262, A292785. %K A066265 nonn %O A066265 0,2 %A A066265 _Patrick De Geest_, Dec 10 2001 %E A066265 More terms from _Hugo Pfoertner_, Jul 22 2003 %E A066265 a(14) from _Robert G. Wilson v_, May 16 2005 %E A066265 a(15)-a(16) from _Donovan Johnson_, Mar 18 2010 %E A066265 a(17)-a(18) from _Dana Jacobsen_, May 11 2014 %E A066265 a(19)-a(21) from _Henri Lifchitz_, Jul 04 2015 %E A066265 a(22)-a(23) from _Henri Lifchitz_, Nov 09 2024