A226019 Primes whose binary reversal is a square.
2, 19, 79, 149, 569, 587, 1237, 2129, 2153, 2237, 2459, 2549, 4129, 4591, 4657, 4999, 8369, 8999, 9587, 9629, 9857, 10061, 17401, 17659, 17737, 18691, 20149, 20479, 33161, 33347, 34631, 35117, 35447, 39023, 40427, 40709, 66403, 68539, 74707, 75703, 79063, 79333, 80071
Offset: 1
Links
- Chai Wah Wu, Table of n, a(n) for n = 1..6182
Programs
-
Mathematica
Select[Table[Prime[j],{j,1,10000}],Element[Sqrt[FromDigits[Reverse[IntegerDigits[#,2]],2]],Integers]&] (* Andres Cicuttin, May 12 2016 *)
-
PARI
isok(k) = isprime(k) && issquare(fromdigits(Vecrev(binary(k)), 2)); \\ Michel Marcus, Feb 19 2021
-
Python
import math primes = [] def addPrime(k): for p in primes: if k%p==0: return if p*p > k: break primes.append(k) r = 0 p = k while k: r = r*2 + (k&1) k>>=1 s = int(math.sqrt(r)) if s*s == r: print(p, end=', ') addPrime(2) addPrime(3) for i in range(5, 1000000000, 6): addPrime(i) addPrime(i+2)
-
Python
from sympy import isprime A226019_list, i, j = [2], 0, 0 while j < 2**34: p = int(format(j,'b')[::-1],2) if j % 2 and isprime(p): A226019_list.append(p) j += 2*i+1 i += 1 A226019_list = sorted(A226019_list) # Chai Wah Wu, Dec 20 2015
-
Python
from sympy import integer_nthroot, primerange def ok(p): return integer_nthroot(int(bin(p)[:1:-1], 2), 2)[1] def aupto(lim): return [p for p in primerange(2, lim+1) if ok(p)] print(aupto(80071)) # Michael S. Branicky, Feb 19 2021
Comments