The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A016041 Primes that are palindromic in base 2 (but written here in base 10). 34

%I #75 Apr 20 2024 16:36:09

%S 3,5,7,17,31,73,107,127,257,313,443,1193,1453,1571,1619,1787,1831,

%T 1879,4889,5113,5189,5557,5869,5981,6211,6827,7607,7759,7919,8191,

%U 17377,18097,18289,19433,19609,19801,21157,22541,22669,22861,23581,24029

%N Primes that are palindromic in base 2 (but written here in base 10).

%C 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

%C 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

%H Robert G. Wilson v, <a href="/A016041/b016041.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from Zak Seidov, terms 1001..3000 from Michael De Vlieger)

%H Kevin S. Brown, <a href="http://www.mathpages.com/home/kmath359.htm">On General Palindromic Numbers</a>

%H Patrick De Geest, <a href="http://www.worldofnumbers.com/palpri.htm">World!Of Palindromic Primes</a>

%F Sum_{n>=1} 1/a(n) = A194097. - _Amiram Eldar_, Mar 19 2021

%t 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 *)

%t pal2Q[n_] := Reverse[x = IntegerDigits[n, 2]] == x; Select[Prime[Range[2800]], pal2Q[#] &] (* _Jayanta Basu_, Jun 23 2013 *)

%t 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 *)

%o (PARI) is(n)=isprime(n)&&Vecrev(n=binary(n))==n \\ _M. F. Hasler_, Feb 23 2018

%o (Magma) [NthPrime(n): n in [1..5000] | (Intseq(NthPrime(n), 2) eq Reverse(Intseq(NthPrime(n), 2)))]; // _Vincenzo Librandi_, Feb 24 2018

%o (Python)

%o from sympy import isprime

%o def ok(n): return isprime(n) and (b:=bin(n)[2:]) == b[::-1]

%o print([k for k in range(10**5) if ok(k)]) # _Michael S. Branicky_, Apr 20 2024

%Y Intersection of A000040 and A006995.

%Y First row of A095749.

%Y A095741 gives the number of terms in range [2^(2n), 2^(2n+1)].

%Y Cf. A095730 (primes whose Zeckendorf expansion is palindromic), A029971 (primes whose ternary (base-3) expansion is palindromic).

%Y Cf. A117697 (written in base 2), A002385, A194097, A256081.

%K nonn,easy,base

%O 1,1

%A _Robert G. Wilson v_

%E More terms from _Patrick De Geest_

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified June 12 06:07 EDT 2024. Contains 373322 sequences. (Running on oeis4.)