cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A020451 Primes that contain digits 1 and 3 only.

This page as a plain text file.
%I A020451 #38 Apr 30 2025 16:20:52
%S A020451 3,11,13,31,113,131,311,313,331,3313,3331,11113,11131,11311,13313,
%T A020451 13331,31333,33113,33311,33331,113111,113131,131111,131113,131311,
%U A020451 311111,313133,313331,313333,331333,333131,333331,1111333,1131113,1131131,1131133,1131331
%N A020451 Primes that contain digits 1 and 3 only.
%H A020451 Jason Bard, <a href="/A020451/b020451.txt">Table of n, a(n) for n = 1..10000</a> (first 1000 terms from Vincenzo Librandi)
%p A020451 N:= 8: # to get all a(n) with at most N digits
%p A020451 S:= {}:
%p A020451 for d from 1 to N do
%p A020451   r:= (10^d-1)/9;
%p A020451   S:= S union select(isprime,map(`+`,map(convert,combinat[powerset]
%p A020451       ({seq(2*10^i,i=0..d-1)}),`+`),r));
%p A020451 od:
%p A020451 S; # if using Maple 11 or earlier, uncomment the next line
%p A020451 # sort(convert(S,list)); # _Robert Israel_, May 04 2015
%t A020451 Flatten[Table[Select[FromDigits/@Tuples[{1,3},n],PrimeQ],{n,7}]] (* _Vincenzo Librandi_, Jul 27 2012 *)
%o A020451 (Magma) [p: p in PrimesUpTo(1131331) | Set(Intseq(p)) subset [1,3]]; // _Bruno Berselli_, Jul 27 2012
%o A020451 (Python)
%o A020451 from sympy import primerange
%o A020451 def checkd(a, c):
%o A020451     b =  set(int(i) for i in set(str(a)))
%o A020451     return b.issubset(c)
%o A020451 for n in primerange(2, 2000000):
%o A020451     if checkd(n, [1, 3]):
%o A020451         print(n)
%o A020451 # _Abhiram R Devesh_, May 04 2015
%Y A020451 Subsequence of A030096, A045429, and A032917.
%K A020451 nonn,base
%O A020451 1,1
%A A020451 _David W. Wilson_