OFFSET
1,1
COMMENTS
See A002385 for palindromic primes in base 10, and A256081 for primes whose binary expansion is "balanced" (see there) but not palindromic. - M. F. Hasler, Mar 14 2015
Number of terms less than 4^k, k=1,2,3,...: 1, 3, 5, 8, 11, 18, 30, 53, 93, 187, 329, 600, 1080, 1936, 3657, 6756, 12328, 23127, 43909, 83377, 156049, 295916, 570396, 1090772, 2077090, 3991187, 7717804, 14825247, 28507572, 54938369, 106350934, ..., partial sums of A095741 plus 1. - Robert G. Wilson v, Feb 23 2018, corrected by Jeppe Stig Nielsen, Jun 17 2023
LINKS
Robert G. Wilson v, Table of n, a(n) for n = 1..10000 (terms 1..1000 from Zak Seidov, terms 1001..3000 from Michael De Vlieger)
Kevin S. Brown, On General Palindromic Numbers
Patrick De Geest, World!Of Palindromic Primes
FORMULA
Sum_{n>=1} 1/a(n) = A194097. - Amiram Eldar, Mar 19 2021
MATHEMATICA
lst = {}; Do[ If[ PrimeQ@n, t = IntegerDigits[n, 2]; If[ FromDigits@t == FromDigits@ Reverse@ t, AppendTo[lst, n]]], {n, 3, 50000, 2}]; lst (* syntax corrected by Robert G. Wilson v, Aug 10 2009 *)
pal2Q[n_] := Reverse[x = IntegerDigits[n, 2]] == x; Select[Prime[Range[2800]], pal2Q[#] &] (* Jayanta Basu, Jun 23 2013 *)
genPal[n_Integer, base_Integer: 10] := Block[{id = IntegerDigits[n, base], insert = Join[{{}}, {# - 1} & /@ Range[base]]}, FromDigits[#, base] & /@ (Join[id, #, Reverse@id] & /@ insert)]; k = 0; lst = {}; While[k < 100, AppendTo[lst, Select[ genPal[k, 2], PrimeQ]]; lst = Flatten@ lst; k++]; lst (* Robert G. Wilson v, Feb 23 2018 *)
PROG
(PARI) is(n)=isprime(n)&&Vecrev(n=binary(n))==n \\ M. F. Hasler, Feb 23 2018
(Magma) [NthPrime(n): n in [1..5000] | (Intseq(NthPrime(n), 2) eq Reverse(Intseq(NthPrime(n), 2)))]; // Vincenzo Librandi, Feb 24 2018
(Python)
from sympy import isprime
def ok(n): return isprime(n) and (b:=bin(n)[2:]) == b[::-1]
print([k for k in range(10**5) if ok(k)]) # Michael S. Branicky, Apr 20 2024
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
EXTENSIONS
More terms from Patrick De Geest
STATUS
approved