login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A020451 Primes that contain digits 1 and 3 only. 9

%I #29 Sep 08 2022 08:44:45

%S 3,11,13,31,113,131,311,313,331,3313,3331,11113,11131,11311,13313,

%T 13331,31333,33113,33311,33331,113111,113131,131111,131113,131311,

%U 311111,313133,313331,313333,331333,333131,333331,1111333,1131113,1131131,1131133,1131331

%N Primes that contain digits 1 and 3 only.

%H Vincenzo Librandi, <a href="/A020451/b020451.txt">Table of n, a(n) for n = 1..1000</a>

%p N:= 8: # to get all a(n) with at most N digits

%p S:= {}:

%p for d from 1 to N do

%p r:= (10^d-1)/9;

%p S:= S union select(isprime,map(`+`,map(convert,combinat[powerset]

%p ({seq(2*10^i,i=0..d-1)}),`+`),r));

%p od:

%p S; # if using Maple 11 or earlier, uncomment the next line

%p # sort(convert(S,list)); # _Robert Israel_, May 04 2015

%t Flatten[Table[Select[FromDigits/@Tuples[{1,3},n],PrimeQ],{n,7}]] (* _Vincenzo Librandi_, Jul 27 2012 *)

%o (Magma) [p: p in PrimesUpTo(1131331) | Set(Intseq(p)) subset [1,3]];

%o // _Bruno Berselli_, Jul 27 2012

%o (Python)

%o from sympy import primerange

%o def checkd(a, c):

%o b = set(int(i) for i in set(str(a)))

%o return b.issubset(c)

%o for n in primerange(2, 2000000):

%o if checkd(n, [1, 3]):

%o print(n)

%o # _Abhiram R Devesh_, May 04 2015

%Y Subsequence of A045429.

%Y Subsequence of A032917.

%K nonn,base

%O 1,1

%A _David W. Wilson_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 16:21 EDT 2024. Contains 371794 sequences. (Running on oeis4.)