Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
FIND THE SUM OF ALL DECIMAL DIGITS APPEARING IN THE NATURAL NUMBERS FROM ONE TO ONE MILLION INCLUSIVEOkay... "all decimal digits." Let's be systematic about this... As instructed, start with 1. sum = 1. Add 2, 3, 4, 5, 6, 7, 8 and 9. sum = 45. In "10", there's a new digit. Namely zero. 45 + 0 = 45. Next up is '11'... Hmm. Already included '1'. Skip it. 12. Did those too. Hey, I see a pattern! The rest, all the way up to a million are just repetitions of the ones we've seen so far. So the answer is 45.:-) In reply to Re: Finding sum of all digits from 1 to 1 million.
by mrbbking
|
|