login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Primes that yield a different prime when rotated by 180 degrees.
6

%I #27 Apr 03 2023 10:36:09

%S 19,61,109,199,601,661,1019,1061,1091,1109,1181,1601,1609,1669,1699,

%T 1811,1901,1999,6011,6091,6101,6199,6619,6661,6689,6691,6899,6991,

%U 10061,10069,10091,10691,10861,10909,11069,11681,11909,16001,16619,16661

%N Primes that yield a different prime when rotated by 180 degrees.

%C Also called invertible primes. [_Lekraj Beedassy_, Jan 03 2009]

%H Reinhard Zumkeller, <a href="/A048890/b048890.txt">Table of n, a(n) for n = 1..1000</a>

%H C. K. Caldwell, The Prime Glossary, <a href="https://t5k.org/glossary/page.php?sort=Strobogrammatic">strobogrammatic</a> [_Lekraj Beedassy_, Jan 03 2009]

%t lst = {}; fQ[n_] := Block[{allset = {0, 1, 6, 8, 9}, id = IntegerDigits@n}, rid = Reverse[id /. {6 -> 9, 9 -> 6}]; Union@ Join[id, allset] == allset && PrimeQ@ FromDigits@ rid && rid != id]; Do[ If[ PrimeQ@n && fQ@n, AppendTo[lst, n]], {n, 16900}]; lst (* _Robert G. Wilson v_, Feb 27 2007 *)

%o (Haskell)

%o import Data.List (unfoldr)

%o a048890 n = a048890_list !! (n-1)

%o a048890_list = filter f a000040_list where

%o f x = all (`elem` [0,1,6,8,9]) ds && x' /= x && a010051 x' == 1

%o where x' = foldl c 0 ds

%o c v 6 = 10*v + 9; c v 9 = 10*v + 6; c v d = 10*v + d

%o ds = unfoldr d x

%o d z = if z == 0 then Nothing else Just $ swap $ divMod z 10

%o -- _Reinhard Zumkeller_, Nov 18 2011

%o (Python)

%o from itertools import product

%o from sympy import isprime

%o A048890_list = []

%o for d in product('01689',repeat=6):

%o s = ''.join(d)

%o p = int(s)

%o if p > 0:

%o q = int(s[::-1].rstrip('0').translate(''.maketrans('69','96')))

%o if p != q and isprime(q) and isprime(p):

%o A048890_list.append(p) # _Chai Wah Wu_, Sep 13 2021

%Y Cf. A007597, A006567, A046732.

%K base,nonn,easy,nice

%O 1,1

%A _G. L. Honaker, Jr._

%E Better definition and more terms from _Robert G. Wilson v_, Feb 27 2007