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”).

A020450
Primes that contain digits 1 and 2 only.
10
2, 11, 211, 2111, 2221, 12211, 21121, 21211, 21221, 22111, 111121, 111211, 112111, 112121, 1111211, 1121221, 1212121, 1212221, 1221221, 2121121, 2211211, 2221111, 11221211, 12111221, 12121121, 12121211, 12122111, 12122221, 12212111, 12222121
OFFSET
1,1
LINKS
MATHEMATICA
Flatten[Table[Select[FromDigits/@Tuples[{1, 2}, n], PrimeQ], {n, 8}]] (* Vincenzo Librandi, Jul 28 2012 *)
PROG
(PARI) for(nd=1, 9, forvec(v=vector(nd, i, [49, 50-(i==nd && i>1)]), isprime(t=eval(Strchr(Vecsmall(v)))) && print1(t", "))) \\ M. F. Hasler, Mar 18 2010
(Magma) [p: p in PrimesUpTo(12222121) | Set(Intseq(p)) subset [1, 2]]; // Vincenzo Librandi, Jul 28 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, 2]):
print(n)
# Abhiram R Devesh, May 08 2015
CROSSREFS
Cf. A020449 (digits 0 & 1), ..., A020472 (digits 8 & 9). [From M. F. Hasler, Mar 18 2010]
Subsequence of A007931.
Sequence in context: A188203 A070256 A356523 * A036229 A104337 A283512
KEYWORD
nonn,base
STATUS
approved