login
Smallest n-digit prime containing only digits 2 and 3.
5

%I #20 Nov 07 2021 19:02:08

%S 2,23,223,2333,23333,222323,2222333,22222223,222323333,2222232323,

%T 22222222223,222222333323,2222222222323,22222222223323,

%U 222222222332233,2222222222323223,22222222222233323,222222222222233323,2222222222222233333,22222222222222232233

%N Smallest n-digit prime containing only digits 2 and 3.

%C It is conjectured that such a prime exists for every value of n.

%H Alois P. Heinz, <a href="/A036937/b036937.txt">Table of n, a(n) for n = 1..400</a>

%H Robert G. Wilson v, <a href="/A069841/a069841.txt">Comments and first 121 terms</a>

%t Do[p = 2(10^n - 1)/9; k = 0; While[ ! PrimeQ[p], k++; p = FromDigits[ PadLeft[ IntegerDigits[k, 2], n] + 2]]; Print[p], {n, 1, 30}] (* _Robert G. Wilson v_, Apr 20 2002 *)

%t Table[SelectFirst[FromDigits/@Tuples[{2,3},n],PrimeQ],{n,20}] (* _Harvey P. Dale_, Nov 07 2021 *)

%o (Python)

%o from sympy import isprime

%o from itertools import product

%o def a(n):

%o for b in product("01", repeat=n):

%o m = int("".join(b).replace("0", "2").replace("1", "3"))

%o if isprime(m): return m

%o return None

%o print([a(n) for n in range(1, 21)]) # _Michael S. Branicky_, Feb 23 2021 after _Robert G. Wilson v_

%Y Cf. A036229, A020458, A036310, A069841.

%K nonn,base

%O 1,1

%A _Patrick De Geest_, Jan 04 1999

%E Edited by _Jon E. Schoenfield_, Mar 27 2014