A385776 Primes having only {1, 2, 9} as digits.
2, 11, 19, 29, 191, 199, 211, 229, 911, 919, 929, 991, 1129, 1229, 1291, 1999, 2111, 2129, 2221, 2999, 9199, 9221, 9929, 11119, 11299, 12119, 12211, 12911, 12919, 19121, 19211, 19219, 19919, 19991, 21121, 21191, 21211, 21221, 21911, 21929, 21991
Offset: 1
Links
Programs
-
Magma
[p: p in PrimesUpTo(10^6) | Set(Intseq(p)) subset [1, 2, 9]];
-
Mathematica
Flatten[Table[Select[FromDigits /@ Tuples[{1, 2, 9}, n], PrimeQ], {n, 7}]]
-
PARI
primes_with(n=50, show=0, L=[1, 2, 9])={for(d=1, 1e9, my(t, u=vector(d, i, 10^(d-i))~); forvec(v=vector(d, i, [1+!(L[1]||(i>1&&i
-
Python
from gmpy2 import is_prime from itertools import count, islice, product def primes_with(digits): # generator of primes having only set(digits) as digits S, E = "".join(sorted(set(digits) - {'0'})), "".join(sorted(set(digits) & set("1379"))) yield from (p for p in [2, 3, 5, 7] if str(p) in digits) yield from (t for d in count(2) for s in S for m in product(digits, repeat=d-2) for e in E if is_prime(t:=int(s+"".join(m)+e))) print(list(islice(primes_with("129"), 41))) # Michael S. Branicky, Jul 11 2025