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.

A354480 a(n) is the smallest decimal palindrome with Hamming weight n (i.e., with exactly n 1's when written in binary).

This page as a plain text file.
%I A354480 #15 Jun 18 2022 14:21:16
%S A354480 0,1,3,7,77,55,111,191,383,767,5115,11711,15351,30703,81918,97279,
%T A354480 744447,978879,1570751,3665663,8387838,66911966,66322366,132111231,
%U A354480 199212991,389545983,939474939,3204444023,3220660223,11542724511,34258485243,33788788733,34292629243
%N A354480 a(n) is the smallest decimal palindrome with Hamming weight n (i.e., with exactly n 1's when written in binary).
%H A354480 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%H A354480 <a href="/index/Pac#palindromes">Index entries for sequences related to palindromes</a>
%o A354480 (Python)
%o A354480 from itertools import count, islice, product
%o A354480 def pals(startd=1): # generator for base-10 palindromes
%o A354480     for d in count(startd):
%o A354480         for p in product("0123456789", repeat=d//2):
%o A354480             if d//2 > 0 and p[0] == "0": continue
%o A354480             left = "".join(p); right = left[::-1]
%o A354480             for mid in [[""], "0123456789"][d%2]:
%o A354480                 yield int(left + mid + right)
%o A354480 def a(n):
%o A354480     for p in pals(startd=len(str(2**n-1))):
%o A354480         if bin(p).count("1") == n:
%o A354480             return p
%o A354480 print([a(n) for n in range(33)]) # _Michael S. Branicky_, Jun 02 2022
%Y A354480 Cf. A000120, A000225, A002113, A061712, A062388, A089226, A089998, A089999, A102029, A114477.
%K A354480 nonn,base
%O A354480 0,3
%A A354480 _Ilya Gutkovskiy_, Jun 02 2022
%E A354480 a(21)-a(32) from _Michael S. Branicky_, Jun 02 2022