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

perl -le "print 1_000_000 * 1_000_001 / 2"
Didn't need Math::BigInt, so i would say there is a problem in the code.

(that formula is one of Guass's, by the way)

UPDATE: details details! :D

seriously, sorry about that, does this help?

$sum += split('',$_) for (1..1_000_000);

You rule, tye! ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--

H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: Finding sum of all digits from 1 to 1 million.
by Anonymous Monk on Jan 24, 2002 at 00:17 UTC
    That tells you the sum of all integers from 1 to 1 million. It doesn't give you the sum of all the digits in those numbers. To illustrate the difference: The sum of all numbers from 1 to 15 is 105 (1 + 2 + 3...+15) The sum of all digits in those numbers is 66 (1 + 2 + 3...+ (1 + 0)... + (1+ 5)) -Beth