login
Smallest prime p such that the decimal expansion of p remains prime through exactly n iterations of base-10 to base-2 conversion (A007088).
0

%I #25 Mar 24 2023 17:49:32

%S 2,3,5,3893257,9632552297

%N Smallest prime p such that the decimal expansion of p remains prime through exactly n iterations of base-10 to base-2 conversion (A007088).

%C Prime numbers that remain primes after 1, 2, 3, and 4 iterations are A065720, A123266, A256621 and A256622, respectively.

%H Carlos Rivera, <a href="http://www.primepuzzles.net/puzzles/puzz_280.htm">Puzzle 280. 3893257</a>, The Prime Puzzles & Problems Connection.

%e a(0) = 2 because prime number 2 in base 2 is 10, and 10 in base 10 is not a prime.

%e a(1) = 3 because 3 = 11_2 and 11_10 is a prime. In the second iteration, however, 11_10 = 1011_2 and 1011_10 is not a prime.

%e a(2) = 5 because 5 = 101_2 and 101_10 = 1100101_2. Both 101 and 1100101 are primes in base 10. In the third iteration, 1100101_10 = 100001100100101000101_2 and 100001100100101000101_10 is not a prime.

%o (Python)

%o from sympy import isprime, nextprime

%o p = 1; mx = 5; I = [*range(mx)]; R = [*range(mx)]

%o while I:

%o p = nextprime(p); ct = 0; q = p

%o while isprime(int(bin(q)[2:])): ct += 1; q = int(bin(q)[2:])

%o if ct in I: R[ct] = p; I.remove(ct)

%o print(*R, sep = ", ")

%Y Cf. A007088, A036952, A065720, A123266, A256621, A256622.

%K nonn,base,more

%O 0,1

%A _Ya-Ping Lu_, Mar 08 2023