login
A020451
Primes that contain digits 1 and 3 only.
9
3, 11, 13, 31, 113, 131, 311, 313, 331, 3313, 3331, 11113, 11131, 11311, 13313, 13331, 31333, 33113, 33311, 33331, 113111, 113131, 131111, 131113, 131311, 311111, 313133, 313331, 313333, 331333, 333131, 333331, 1111333, 1131113, 1131131, 1131133, 1131331
OFFSET
1,1
LINKS
MAPLE
N:= 8: # to get all a(n) with at most N digits
S:= {}:
for d from 1 to N do
r:= (10^d-1)/9;
S:= S union select(isprime, map(`+`, map(convert, combinat[powerset]
({seq(2*10^i, i=0..d-1)}), `+`), r));
od:
S; # if using Maple 11 or earlier, uncomment the next line
# sort(convert(S, list)); # Robert Israel, May 04 2015
MATHEMATICA
Flatten[Table[Select[FromDigits/@Tuples[{1, 3}, n], PrimeQ], {n, 7}]] (* Vincenzo Librandi, Jul 27 2012 *)
PROG
(Magma) [p: p in PrimesUpTo(1131331) | Set(Intseq(p)) subset [1, 3]];
// Bruno Berselli, Jul 27 2012
(Python)
from sympy import primerange
def checkd(a, c):
b = set(int(i) for i in set(str(a)))
return b.issubset(c)
for n in primerange(2, 2000000):
if checkd(n, [1, 3]):
print(n)
# Abhiram R Devesh, May 04 2015
CROSSREFS
Subsequence of A045429.
Subsequence of A032917.
Sequence in context: A260044 A199303 A244047 * A018450 A302304 A119145
KEYWORD
nonn,base
STATUS
approved