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.
%I A144753 #23 Sep 17 2021 17:26:17 %S A144753 3,5,7,9,17,21,31,33,65,73,93,107,127,129,257,273,313,341,381,403,443, %T A144753 471,513,1025,1057,1137,1193,1273,1317,1397,1453,1571,1651,1707,1831, %U A144753 2047,2049,4097,4161,4321,4433,4593,4681,4841,4953,5189,5349,5461,5709 %N A144753 Positive integers whose binary representation is a palindrome and has a prime number of 1's. %C A144753 Each term of this sequence is in both A006995 and A052294. %H A144753 Indranil Ghosh, <a href="/A144753/b144753.txt">Table of n, a(n) for n = 1..11167</a> (terms 1..1000 from Vincenzo Librandi) %e A144753 21 in binary is 10101. This binary representation is a palindrome, it contains three 1's, and three is a prime. So 21 is a term. %t A144753 okQ[n_] := Module[{idn2 = IntegerDigits[n, 2]}, (idn2 == Reverse[idn2]) && PrimeQ[First[DigitCount[n, 2]]]];Select[Range[10000], okQ] (* _Harvey P. Dale_, Sep 23 2008 *) %o A144753 (Python) %o A144753 from sympy import isprime %o A144753 def ok(n): b = bin(n)[2:]; return b == b[::-1] and isprime(b.count("1")) %o A144753 print(list(filter(ok, range(5710)))) # _Michael S. Branicky_, Sep 17 2021 %o A144753 (Python) # faster for computing initial segment of sequence %o A144753 from sympy import isprime %o A144753 from itertools import product %o A144753 def ok2(bin_str): return isprime(bin_str.count("1")) %o A144753 def bin_pals(maxdigits): %o A144753 yield from "01" %o A144753 digits, midrange = 2, [[""], ["0", "1"]] %o A144753 for digits in range(2, maxdigits+1): %o A144753 for p in product("01", repeat=digits//2-1): %o A144753 left = "1"+"".join(p) %o A144753 for middle in midrange[digits%2]: %o A144753 yield left + middle + left[::-1] %o A144753 def auptopow2(e): return [int(b, 2) for b in filter(ok2, bin_pals(e))] %o A144753 print(auptopow2(13)) # _Michael S. Branicky_, Sep 17 2021 %Y A144753 Cf. A144752, A006995, A052294. %K A144753 base,nonn %O A144753 1,1 %A A144753 _Leroy Quet_, Sep 20 2008 %E A144753 More terms from _Harvey P. Dale_, Sep 23 2008 %E A144753 Name edited by _Michael S. Branicky_, Sep 17 2021