Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Finding sum of all digits from 1 to 1 million.

by flexvault (Parson)
on Jan 30, 2013 at 19:32 UTC ( #1016144=note: print w/ replies, xml ) Need Help??


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

vladb,

I confused by the term 'DECIMAL DIGITS'. In the following sequence, I would count the number of decimal digits as:

100 sum: 3 101 sum: 6 102 sum: 9 ...
In those 3 numbers, we have a total of 9 digits.

So if I use this code:

perl -E '$sum=0;for(1..1e6){$sum+=length($_);} say $sum;'
The result printed as 5888896, which is not 27000001.

So how is the term 'DECIMAL DIGITS' defined? I think that is key to solving for the "real" answer.

Regards...Ed

"Well done is better than well said." - Benjamin Franklin


Comment on Re: Finding sum of all digits from 1 to 1 million.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016144]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-09-20 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls