huge speedup

This algorithm halves numbers and writes the rest of the divisions to the solution. The old algorithm used to decrement the input value at each step (which took quite some time).