|
|
A016041
|
|
Primes that are palindromic in base 2 (but written here in base 10).
|
|
35
|
|
|
3, 5, 7, 17, 31, 73, 107, 127, 257, 313, 443, 1193, 1453, 1571, 1619, 1787, 1831, 1879, 4889, 5113, 5189, 5557, 5869, 5981, 6211, 6827, 7607, 7759, 7919, 8191, 17377, 18097, 18289, 19433, 19609, 19801, 21157, 22541, 22669, 22861, 23581, 24029
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
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
|
|
|
FORMULA
|
|
|
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]
|
|
CROSSREFS
|
A095741 gives the number of terms in range [2^(2n), 2^(2n+1)].
Cf. A095730 (primes whose Zeckendorf expansion is palindromic), A029971 (primes whose ternary (base-3) expansion is palindromic).
|
|
KEYWORD
|
nonn,easy,base
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|