cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A204232 Numbers whose binary reversal is prime.

This page as a plain text file.
%I A204232 #36 Oct 29 2024 06:24:44
%S A204232 3,5,6,7,10,11,12,13,14,17,20,22,23,24,25,26,28,29,31,34,37,40,41,43,
%T A204232 44,46,47,48,50,52,53,55,56,58,61,62,67,68,71,73,74,77,80,82,83,86,88,
%U A204232 91,92,94,96,97,100,101,104,106,107,110,112,113,115,116,121
%N A204232 Numbers whose binary reversal is prime.
%C A204232 Base-2 analog of A095179.
%C A204232 If k is a term, then 2*k is a term too. - _Michel Marcus_, Apr 19 2020
%H A204232 Michel Marcus, <a href="/A204232/b204232.txt">Table of n, a(n) for n = 1..1000</a>
%e A204232 3, 5 and 7 are in the sequence because their binary reversal, equal to themselves, is prime.
%e A204232 a(3)=6 is in the sequence, because 6=110[2] (written in base 2), whose reversal 011[2]=3 is prime.
%e A204232 a(5)=11 is in the sequence, because 11=1011[2] (written in base 2), whose reversal 1101[2]=13 is prime.
%t A204232 Select[Range[170], PrimeQ[FromDigits[Reverse[IntegerDigits[#, 2]], 2]] &] (* _Alonso del Arte_, Jan 13 2012 *)
%o A204232 (PARI) for(n=1,1e2,isprime((t=binary(n))*vector(#t,i,1<<i)~\2) & print1(n","))
%o A204232 (Python)
%o A204232 from sympy import isprime
%o A204232 def ok(n): return isprime(int(bin(n)[2:][::-1], 2))
%o A204232 print(list(filter(ok, range(1, 122)))) # _Michael S. Branicky_, Sep 06 2021
%o A204232 (Python) # alternate program constructing terms directly from primes
%o A204232 from sympy import isprime, primerange
%o A204232 def auptobits(maxbits):
%o A204232     alst = []
%o A204232     for p in primerange(3, 1<<maxbits):
%o A204232         b = bin(p)[2:]; br = b[::-1]; t = int(br, 2)
%o A204232         alst.extend(t<<i for i in range(maxbits-len(br)+1))
%o A204232     return sorted(alst)
%o A204232 print(auptobits(7)) # _Michael S. Branicky_, Oct 29 2024
%Y A204232 Cf. A030101, A095179.
%Y A204232 Positions of 2's in A227864.
%K A204232 nonn,base,easy
%O A204232 1,1
%A A204232 _M. F. Hasler_, Jan 13 2012