A376615 a(n) is the number of iterations that n requires to reach a noninteger under the map x -> x / wt(x), where wt(k) is the binary weight of k (A000120); a(n) = 0 if n is a power of 2.
0, 0, 1, 0, 1, 2, 1, 0, 1, 2, 1, 3, 1, 1, 1, 0, 1, 2, 1, 3, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 3, 1, 1, 1, 4, 1, 2, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 0, 1, 2, 1, 3, 2, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 5, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 1
Examples
a(6) = 2 since 6/wt(6) = 3 and 3/wt(3) = 3/2 is a noninteger that is reached after 2 iterations. a(20) = 3 since 20/wt(20) = 10, 10/wt(10) = 5 and 5/wt(5) = 5/2 is a noninteger that is reached after 3 iterations.
Links
- Amiram Eldar, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
a[n_] := a[n] = Module[{bw = DigitCount[n, 2, 1]}, If[bw == 1, 0, If[!Divisible[n, bw], 1, 1 + a[n/bw]]]]; Array[a, 100]
-
PARI
a(n) = {my(w = hammingweight(n)); if(w == 1, 0, if(n % w, 1, 1 + a(n/w)));}
Comments