in reply to Finding sum of all digits from 1 to 1 million.

I think you may be right. I don't think the answer you have is correct. There is actualy a formula to calculate the sum of the numbers from 1-n. It is (n^2)/2 + n/2 which in the case of n=1000000 the answer is 500000500000

---If it doesn't fit use a bigger hammer

---If it doesn't fit use a bigger hammer

Replies are listed 'Best First'. | |
---|---|

Re^2: Finding sum of all digits from 1 to 1 million.
by Anonymous Monk on Jan 30, 2013 at 08:59 UTC |

In Section
Seekers of Perl Wisdom

Comment onRe: Finding sum of all digits from 1 to 1 million.