login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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 A030096, A045429, and A032917.
Sequence in context: A260044 A199303 A244047 * A018450 A302304 A119145
KEYWORD
nonn,base
STATUS
approved