A357759 Numbers k such that in the binary expansion of k, the Hamming weight of each block differs by at most 2 from every other block of the same length.
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75
Offset: 1
Examples
For k = 12: - the binary expansion of k is "1100", - blocks of length 1 have Hamming weight 0 or 1, - blocks of length 2 have Hamming weight 0, 1 or 2, - blocks of length 3 have Hamming weight 1 or 2, - blocks of length 4 have Hamming weight 2, - so 12 belongs to the sequence. For k = 56: - the binary expansion of 44 is "111000", - blocks of length 3 have Hamming weight 0, 1, 2 or 3, - so 56 does not belong to the sequence.
Links
- Andrew Howroyd, Table of n, a(n) for n = 1..7658
- Rémy Sigrist, PARI program
- Index entries for sequences related to binary expansion of n
Programs
-
PARI
\\ See Links section.
-
Python
def ok(n): b = bin(n)[2:] if "000" in b and "111" in b: return False for l in range(4, len(b)-1): h = set(b[i:i+l].count("1") for i in range(len(b)-l+1)) if max(h) - min(h) > 2: return False return True print([k for k in range(69) if ok(k)]) # Michael S. Branicky, Oct 12 2022
Extensions
a(69) onwards from Andrew Howroyd, Oct 09 2024
Comments