A103545 Largest n-digit zeroless prime with nonprime digits.
89, 991, 9949, 99991, 999961, 9999991, 99999989, 999999491, 9999999881, 99999999689, 999999999989, 9999999999161, 99999999999481, 999999999999989, 9999999999999641, 99999999999999961, 999999999999999989, 9999999999999999961, 99999999999999999989
Offset: 2
Links
- Michael S. Branicky, Table of n, a(n) for n = 2..1000
Crossrefs
Cf. A103544.
Programs
-
Mathematica
PrevPrim[n_] := Block[{k = n - 1}, While[ !PrimeQ[k], k-- ]; k]; f[n_] := Block[{pp = PrevPrim[ 10^n]}, While[ Union[ Join[{1, 4, 6, 8, 9}, IntegerDigits[pp]]] != {1, 4, 6, 8, 9}, pp = PrevPrim[pp]]; pp]; Table[ f[n], {n, 2, 18}] (* Robert G. Wilson v, Mar 26 2005 *)
-
Python
from sympy import isprime from itertools import product def a(n): for p in product("98641", repeat=n): t = int("".join(p)) if isprime(t): return t print([a(n) for n in range(2, 22)]) # Michael S. Branicky, Aug 10 2022
Extensions
More terms from Jonathan Vos Post, Mar 23 2005
a(7) to a(12) from Jonathan Vos Post, Mar 23 2005
a(13) to a(18) from Robert G. Wilson v, Mar 26 2005
a(19) and beyond from Michael S. Branicky, Aug 10 2022