For a pair of numbers the number of actions is equal to <length of the first number> + <length of the second number> - 2*<length of the longest common prefix> (numbers are treated as binary strings)
Your must understand hint of 'aropan'. And get answer = 2^L*(L - 3*2^L + L*2^L + 3) P.S.: Mathcad can help you to find sum of such expression as FOR(z=0,..l)z*2^z. It's only math problem. P.P.S.: To find 2^L use http://en.wikipedia.org/wiki/Exponentiation_by_squaring