← RoseCode

ROSECODE 513

Runs Resistance

Min_25 · Math ·

Let A0(n) be the array of the binary representation of positive integer n.

For example, A0(1)=[1], A0(2)=[1,0] and A0(11)=[1,0,1,1].

Let R(A) be the function that returns the array of run-lengths of the given array A.

For example, R([1,0])=[1,1], R([1,0,1,1])=[1,1,2] and R([1,0,0,0,1])=[1,3,1].

Let Ak(n):=R(Ak1(n)) for k1, and M(n) be the minimum integer k (0) such that |Ak(n)|=1, where |A| denotes the length of A.

Finally, let S(n):=i=1nM(i).

You can verify that M(1)=0, M(2)=2, M(3)=1, M(11)=4, S(100)=346 and S(1234567)=6717538.

Find S(1234567654321).