good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
use the formul ...
<RB> (n+1)*n/2 Why does this work? look at this ... 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 is the same as 1 + 10 + 2 + 9 + 3 + 8 + 4 + 7 + 5 + 6 which is the same as 11 + 11 + 11 + 11 + 11 which is 11*5 = (n+1)*n/2 where n = 10 In reply to Re: Finding sum of all digits from 1 to 1 million.
by rbc
|
|