|
|
A292895
|
|
a(n) is the least positive k such that the Hamming weight of k equals the Hamming weight of k + n.
|
|
2
|
|
|
1, 1, 2, 1, 4, 5, 2, 1, 8, 3, 10, 6, 4, 5, 2, 1, 16, 3, 6, 5, 20, 3, 12, 10, 8, 9, 10, 6, 4, 5, 2, 1, 32, 3, 6, 5, 12, 3, 10, 9, 40, 11, 6, 5, 24, 3, 20, 18, 16, 7, 18, 17, 20, 12, 12, 10, 8, 9, 10, 6, 4, 5, 2, 1, 64, 3, 6, 5, 12, 3, 10, 9, 24, 11, 6, 5, 20, 3, 18, 17, 80, 7, 22, 14, 12, 13, 10, 9, 48
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
The Hamming weight of a number n is given by A000120(n).
Let b(n) be the smallest t such that a(t) = n. Initial values of b(n) are 0, 2, 9, 4, 5, 11, 49, 8, 25, 10, 41, 22, 85, 83, 225, 16, 51, 47, 177, 20, ... See the logarithmic line graph of first 10^3 terms of b(n) sequence in Links section.
|
|
LINKS
|
|
|
FORMULA
|
a(n) <= n for n >= 1.
a(2*n) = 2*a(n) for n >= 1.
a(2^m) = 2^m and a(5*2^m) = 5*2^m for m >= 0.
a(2^m - 1) = 1 for m >= 0.
a(2^m + 1) = 3 and a(2^m - 3) = 5 for m >= 3.
a(2^m + 3) = 5 for m >= 4.
a((2^m - 1)^2) = 2^m - 1 for m >= 1.
a(2^(m + 2) + 2^m - 1) = 2^m + 1 m >= 1.
a((2^m + 1)^2) = 7 for m >= 3.
|
|
EXAMPLE
|
a(49) = 7 since A000120(7) = A000120(7 + 49) and 7 is the least number with this property.
|
|
MAPLE
|
N:= 1000: # to get all terms before the first where n+a(n)>N
H:= Array(0..N, t -> convert(convert(t, base, 2), `+`)):
f:= proc(n) local k;
for k from 1 to N-n do
if H[k]=H[k+n] then return k fi
od:
0
end proc:
R:= NULL:
for n from 0 do
v:= f(n);
if v = 0 then break fi;
R:= R, v;
od:
|
|
MATHEMATICA
|
h[n_] := First@ DigitCount[n, 2]; a[n_] := Block[{k=1}, While[h[k] != h[k + n], k++]; k]; Array[a, 90] (* Giovanni Resta, Sep 28 2017 *)
|
|
PROG
|
(PARI) a(n) = {my(k=1); while ((hammingweight(k)) != hammingweight(n+k), k++); k; }
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|