login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Largest n-digit semiprime.
6

%I #17 Sep 18 2021 07:17:05

%S 9,95,998,9998,99998,999997,9999998,99999997,999999991,9999999997,

%T 99999999997,999999999997,9999999999989,99999999999997,

%U 999999999999998,9999999999999994,99999999999999989,999999999999999993,9999999999999999991,99999999999999999983

%N Largest n-digit semiprime.

%H Amiram Eldar, <a href="/A098450/b098450.txt">Table of n, a(n) for n = 1..100</a>

%F a(n) = 10^n - A119320(n). - _Amiram Eldar_, Sep 18 2021

%t NextSemiPrime[n_, k_: 1] := Block[{c = 0, sgn = Sign[k]}, sp = n + sgn; While[c < Abs[k], While[ PrimeOmega[sp] != 2, If[sgn < 0, sp--, sp++]]; If[sgn < 0, sp--, sp++]; c++]; sp + If[sgn < 0, 1, -1]]; f[n_] := NextSemiPrime[10^n, -1]; Array[f, 18] (* _Robert G. Wilson v_, Dec 18 2012 *)

%o (PARI) apply( A098450(n)={n=10^n;until(bigomega(n-=1)==2,);n}, [1..20]) \\ _M. F. Hasler_, Jan 01 2021

%o (Python)

%o from sympy import factorint

%o def semiprime(n): f = factorint(n); return sum(f[p] for p in f) == 2

%o def a(n):

%o an = 10**n - 1

%o while not semiprime(an): an -= 1

%o return an

%o print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Apr 10 2021

%Y Cf. A098449 (smallest n-digit semiprime), A003618 (largest n-digit prime), A001358 (semiprimes), A119320.

%K base,nonn

%O 1,1

%A _Rick L. Shepherd_, Sep 07 2004