Let $\operatorname{wt}(n)$ be A000120, i.e., number of $1$'s in binary expansion of $n$ (or the binary weight of $n$).
Then we have an integer sequence given by $$a(n)=n(n+1)-\sum\limits_{k=0}^{n}\operatorname{wt}(k)$$
Given $n$ balls, all of which are initially in the first of $n$ numbered boxes, $b(n)$ is the number of steps required to get $n$ balls in the last box when a step consists of moving to the next box every second ball and also moving (except for the first box) to the previous box the same number of balls from the lowest-numbered box that has at least one ball (if we have only one ball in a box, then we just move it to the next box).
In other words, we initially choose the lowest-numbered box that has at least one ball and:
- if there is only one ball in the box, we just move it to the next box.
- if we have selected the first box and number of balls is bigger than $1$, we simply move the half rounded down balls to the next box.
- if we have selected any other box and number of balls is bigger than $1$, we simply move the half rounded down balls to the next box and move the half rounded down balls to the previous box.
Using notation described by Peter J. Taylor in comments, we have:
If $d_t(i)$ denotes the number of balls in box $i$ after step $t$ we have $d_0(i)=n[i=1]$ using Iverson brackets; let $j$ be the number of the lowest-numbered box that has at least one ball, then we have:
- if $d_t(j)=1$, then $d_{t+1}(j)=d_t(j)-1$ and $d_{t+1}(j+1)=d_t(j+1)+1$.
- if $j=1$ and $d_t(j)>1$, then $d_{t+1}(j)=d_t(j)-\left\lfloor\frac{d_t(j)}{2}\right\rfloor$ and $d_{t+1}(j+1)=d_t(j+1)+\left\lfloor\frac{d_t(j)}{2}\right\rfloor$.
- if $j>1$ and $d_t(j)>1$, then $d_{t+1}(j)=d_t(j)-2\left\lfloor\frac{d_t(j)}{2}\right\rfloor$, $d_{t+1}(j+1)=d_t(j+1)+\left\lfloor\frac{d_t(j)}{2}\right\rfloor$ and $d_{t+1}(j-1)=d_t(j-1)+\left\lfloor\frac{d_t(j)}{2}\right\rfloor$.
I conjecture that $b(n)=2a(n-1)$.
One may verify this conjecture using this PARI prog:
a(n)=my(A, B, v); v=vector(n, i, 0); v[1]=n; A=0; while(v[n]!=n, B=1; while(v[B]<1, B++); v[B+1]+=if(v[B]==1,1,v[B]\2); if(B>1,v[B-1]+=v[B]\2); v[B]-=if(v[B]==1,1,(1+(B>1))*(v[B]\2)); A++); A
Is there a way to prove it?