32 mins ago, by
Balarka Sen Hm, if the binary expansion of $n$ is, read from right-to-left, 0...(a_1 times)...01...(b_1 times)...10...(a_2 times)...01...(b_2 times)...1..., then after $\sum (a_k + b_k) + \ell$ moves, where $\ell$ is length of the binary expansion, I think the algorithm terminates.