A089971 Primes whose decimal representation also represents a prime in base 2.
11, 101, 10111, 101111, 1011001, 1100101, 10010101, 10011101, 10100011, 10101101, 10110011, 11000111, 11100101, 100111001, 101001011, 101101111, 101111011, 101111111, 110111011, 111001001, 1000001011, 1001001011, 1001110111, 1010000011, 1010000111, 1010001101
Offset: 1
Examples
a(1)=11 is a prime and its decimal representation is also a valid base-2 representation (because all digits are < 2), and 11_2 = 3_10 is again a prime.
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
- Alejandro J. Becerra Jr., Python code for computing terms of A089971, A089981, A090707-A090710, A235394-A235395.
- Alejandro J. Becerra Jr., Table of n, a(n) for n = 1..42012
Crossrefs
Programs
-
Mathematica
Select[ FromDigits@# & /@ IntegerDigits[ Prime@ Range@ 270, 2], PrimeQ] (* Robert G. Wilson v, Jan 05 2014 *)
-
PARI
is_A089971(p)=vecmax(d=digits(p))<2&&isprime(vector(#d, i, 2^(#d-i))*d~)&&isprime(p) \\ "d" is implicitly declared local. Putting isprime(p) to the end improves performance when the function is applied to primes only or to very large numbers. - M. F. Hasler, Jan 05 2014
-
PARI
fixBase(n, oldBase, newBase)=my(d=digits(n, oldBase), t=newBase-1); for(i=1, #d, if(d[i]>t, for(j=i, #d, d[j]=t); break)); fromdigits(d, newBase) list(lim)=my(v=List(), t); forprime(p=2, fixBase(lim\1, 10, 2), if(isprime(t=fromdigits(digits(p, 2), 10)), listput(v, t))); Vec(v) \\ Charles R Greathouse IV, Nov 07 2016
-
Python
from sympy import isprime, primerange def aupto(limit): alst = [] for p in primerange(2, limit+1): t = int(bin(p)[2:]) if isprime(t): alst.append(t) return alst print(aupto(2**11)) # Michael S. Branicky, Aug 19 2021
Extensions
Definition and example reworded, offset corrected, and cross-references added by M. F. Hasler, Jan 05 2014
Comments