login
Primes that contain digits 8 and 9 only.
35

%I #34 Nov 15 2022 13:56:11

%S 89,8999,89899,89989,98899,98999,99989,888989,898889,989999,998989,

%T 8888989,8889889,8988989,8989999,8998889,8999899,9888889,9889889,

%U 9899999,9989899,9999889,88888999,88898989,88989899,89888989,89889889,89898889,89999999,98888989

%N Primes that contain digits 8 and 9 only.

%C Or, primes with minimal digit 8.

%H Michael S. Branicky, <a href="/A020472/b020472.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from Vincenzo Librandi)

%H <a href="/index/Pri#PrimesWithDigits">Index to entries about primes with digits in a given set</a>

%t Select[Prime[Range[80000]], Min[IntegerDigits[#]] == 8 &] (* _Zak Seidov_, May 07 2005 *)

%t Flatten[Table[Select[FromDigits/@Tuples[{8, 9}, n], PrimeQ], {n, 8}]] (* _Vincenzo Librandi_, Jul 27 2012 *)

%o (PARI) for(nd=1,9, p=vector(nd,i,10^(nd-i))~; forvec(v=vector(nd,i,[8+(i==nd),9]), isprime(v*p) && print1(v*p","))) \\ _M. F. Hasler_, Mar 18 2010

%o (Python)

%o from sympy import isprime

%o from itertools import count, islice, product

%o def agen(): # generator of terms

%o for d in count(2):

%o for first in product("89", repeat=d-1):

%o t = int("".join(first) + "9")

%o if isprime(t): yield t

%o print(list(islice(agen(), 30))) # _Michael S. Branicky_, Nov 15 2022

%Y Cf. A020449 (digits 0 & 1), ..., A020471 (digits 7 & 9). - _M. F. Hasler_, Mar 18 2010

%K nonn,base

%O 1,1

%A _David W. Wilson_

%E Edited by _N. J. A. Sloane_, Jan 26 2008 at the suggestion of _Lekraj Beedassy_