A292895 a(n) is the least positive k such that the Hamming weight of k equals the Hamming weight of k + n.
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
Offset: 0
Examples
a(49) = 7 since A000120(7) = A000120(7 + 49) and 7 is the least number with this property.
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..16384
- Altug Alkan, A logarithmic scatterplot of a(n) for n <= 10^6
- Altug Alkan, A logarithmic line graph of b(n) for n <= 10^3
Programs
-
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: R; # Robert Israel, Sep 27 2017
-
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 *)
-
PARI
a(n) = {my(k=1); while ((hammingweight(k)) != hammingweight(n+k), k++); k; }
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.
Comments