A352785 Numbers k such that w(k - w(k)) = w(k), where w(k) is the binary weight of k, A000120(k).
0, 2, 5, 12, 14, 20, 22, 25, 27, 28, 36, 38, 41, 43, 44, 52, 57, 58, 68, 70, 73, 75, 76, 84, 89, 90, 100, 105, 106, 115, 120, 122, 125, 132, 134, 137, 139, 140, 148, 153, 154, 164, 169, 170, 179, 184, 186, 189, 196, 201, 202, 211, 216, 218, 221, 232, 234, 237, 241, 243, 249, 252, 254, 260, 262, 265, 267, 268, 276
Offset: 1
Examples
k = 20; A000120(20 - A000120(20)) = A000120(20), thus k = 20 is a term.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000
Programs
-
Maple
q:= n-> (w-> w(n-w(n))=w(n))(k-> add(i, i=Bits[Split](k))): select(q, [$0..300])[]; # Alois P. Heinz, May 24 2022
-
Mathematica
w[n_] := DigitCount[n, 2, 1]; Select[Range[0, 300], w[# - w[#]] == w[#] &] (* Amiram Eldar, Apr 02 2022 *)
-
Python
def w(n): return bin(n).count("1") def ok(n): wn = w(n); return w(n - wn) == wn print([k for k in range(277) if ok(k)]) # Michael S. Branicky, Apr 02 2022