Code changed to fit the problem better

Note that the maximum value of n is currently set to 10^7, as 10^5 does
not show the loss of precision.