login
Smallest n-digit prime containing only digits 3 and 5, or 0 if no such prime exists.
1

%I #18 Oct 10 2019 23:00:53

%S 3,53,353,3533,33353,333533,3335533,33335333,333535333,3333353533,

%T 33333353533,333333533353,3333333353353,33333333555553,

%U 333333333353353,3333333333333533,33333333333355333,333333333333353533

%N Smallest n-digit prime containing only digits 3 and 5, or 0 if no such prime exists.

%H Robert Israel, <a href="/A036941/b036941.txt">Table of n, a(n) for n = 1..990</a>

%p A:= proc(n) local j,x,t;

%p x:= (10^n-1)/3;

%p for t from 1 to 2^n do

%p if isprime(x) then return x fi;

%p j:= padic:-ordp(t,2);

%p x:= x - (x mod 10^j) + (7 * 10^j-1)/3;

%p od:

%p 0

%p end proc:

%p seq(A(n),n=1..100); # _Robert Israel_, Apr 22 2016

%t Table[SelectFirst[FromDigits/@(Join[#,{3}]&/@Tuples[{3,5},n]),PrimeQ],{n,0,20}](* The program uses the SelectFirst function from Mathematica version 10 *) (* _Harvey P. Dale_, Oct 07 2014 *)

%Y Cf. A036229, A020462, A036315.

%K nonn,base

%O 1,1

%A _Patrick De Geest_, Jan 04 1999