OFFSET
2,1
LINKS
Robert Israel, Table of n, a(n) for n = 2..999
MAPLE
f:= proc(n) local t, x, L, y;
t:= (10^n-1)/9;
for x from 0 to 5^n-1 do
L:= subs({1=3, 2=5, 3=7, 4=8}, convert(x, base, 5));
y:= t+add(10^(i-1)*L[i], i=1..nops(L));
if isprime(y) then return y fi
od;
FAIL
end proc:
map(f, [$2..20]); # Robert Israel, Sep 28 2018
MATHEMATICA
NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; f[n_] := Block[{np = NextPrim[(10^n - 1)/9 - 1]}, While[ Union[ Join[{1, 4, 6, 8, 9}, IntegerDigits[np]]] != {1, 4, 6, 8, 9}, np = NextPrim[np]]; np]; Table[ f[n], {n, 2, 18}] (* Robert G. Wilson v, Mar 23 2005 *)
ndzp[n_]:=Module[{np=NextPrime[FromDigits[PadRight[{}, n, 1]]]}, While[ !SubsetQ[ {1, 4, 6, 8, 9}, IntegerDigits[ np]], np =NextPrime[np]]; np]; Join[{11}, Array[ndzp, 16, 3]] (* Harvey P. Dale, Aug 28 2021 *)
PROG
(Python)
from sympy import isprime
from itertools import product
def a(n):
for p in product("14689", repeat=n):
t = int("".join(p))
if isprime(t): return t
print([a(n) for n in range(2, 22)]) # Michael S. Branicky, Aug 20 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Ray G. Opao, Mar 22 2005
EXTENSIONS
More terms from Robert G. Wilson v, Mar 23 2005
STATUS
approved