%I #21 Feb 17 2024 00:46:10
%S 191,691,811,991,1009,1069,1619,1801,1861,1889,6089,6869,6911,6961,
%T 8101,8191,8609,8669,8689,9001,9811,10009,10099,10111,10169,10181,
%U 10601,10889,10891,11119,11161,11689,11699,11801,11969,11981,16061,16691,16699,18089,18119
%N Primes that become semiprimes when turned upside down.
%H Michael S. Branicky, <a href="/A347294/b347294.txt">Table of n, a(n) for n = 1..10000</a>
%H C. K. Caldwell, and G. L. Honaker, Jr., <a href="https://primes.utm.edu/curios/page.php?curio_id=42832">Prime Curio for 191</a>.
%e 811 is a term because when 811 is turned upside down (rotated 180 degrees) it becomes 118=2*59, a semiprime.
%t semiQ[n_] := PrimeOmega[n] == 2; q[n_] := PrimeQ[n] && Module[{d = IntegerDigits[n]}, AllTrue[d, MemberQ[{0, 1, 6, 8, 9}, #] &] && semiQ[FromDigits[Reverse[d] /. {6 -> 9, 9 -> 6}]]]; Select[Range[20000], q] (* _Amiram Eldar_, Jan 23 2022 *)
%o (Python)
%o from sympy import isprime, factorint
%o from itertools import count, islice, product
%o def f(s): return s[::-1].translate({ord("6"):ord("9"), ord("9"):ord("6")})
%o def agen():
%o for digits in count(3):
%o for first in "1689":
%o for mid in product("01689", repeat=digits-2):
%o for last in "19":
%o s = first + "".join(mid) + last
%o t = int(s)
%o if isprime(t):
%o flip = f(s)
%o if sum(factorint(int(flip)).values()) == 2:
%o yield t
%o print(list(islice(agen(), 41))) # _Michael S. Branicky_, Feb 16 2024
%Y Cf. A000040, A001358, A048889.
%K nonn,base
%O 1,1
%A _G. L. Honaker, Jr._, Jan 22 2022
%E More terms from _Amiram Eldar_, Jan 23 2022