login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A046477 Palindromic primes in bases 8 and 10. 0
2, 3, 5, 7, 373, 13331, 30103, 1496941, 1970791 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,1

COMMENTS

Any other terms have more than 20 digits. - Michael S. Branicky, Dec 19 2020

LINKS

Table of n, a(n) for n=1..9.

Patrick De Geest, World!Of Palindromic Primes

MATHEMATICA

Do[s = RealDigits[n, 8][[1]]; t = RealDigits[n, 10][[1]]; If[PrimeQ[n], If[FromDigits[t] == FromDigits[Reverse[t]], If[FromDigits[s] == FromDigits[Reverse[s]], Print[n]]]], {n, 1, 10^5}]

PROG

(Python) # efficiently search to large numbers

from sympy import isprime

from itertools import product

def candidate_prime_pals(digits):

  ruled_out = "024568" # can't be even or multiple of 5

  midrange = [[""], "0123456789"]

  for p in product("0123456789", repeat=digits//2):

    left = "".join(p)

    if len(left):

      if left[0] in ruled_out: continue

    for middle in midrange[digits%2]:

      yield left+middle+left[::-1]

for digits in range(1, 15):

  for p in candidate_prime_pals(digits):

    intp = int(p); octp = oct(intp)[2:]

    if octp==octp[::-1]:

      if isprime(intp):

        print(intp, end=", ") # Michael S. Branicky, Dec 19 2020

(Python) # alternate sufficient for producing terms through a(9)

from sympy import isprime

def ispal(n): strn = str(n); return strn==strn[::-1]

for n in range(10**7):

  if ispal(n) and ispal(oct(n)[2:]) and isprime(n):

    print(n) # Michael S. Branicky, Dec 20 2020

(PARI) is(n) = my(d=digits(n, 8), dd=digits(n)); d==Vecrev(d) && dd==Vecrev(dd)

forprime(p=1, , if(is(p), print1(p, ", "))) \\ Felix Fröhlich, Dec 20 2020

CROSSREFS

Cf. A002113, A002385, A029976, A029804.

Sequence in context: A052025 A045336 A083183 * A145843 A090720 A114780

Adjacent sequences:  A046474 A046475 A046476 * A046478 A046479 A046480

KEYWORD

nonn,hard,base,more

AUTHOR

Patrick De Geest, Aug 15 1998

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified March 6 12:57 EST 2021. Contains 341847 sequences. (Running on oeis4.)