Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re (tilly) 3: Finding sum of all digits from 1 to 1 million.

by tilly (Archbishop)
on Jan 24, 2002 at 01:06 UTC ( [id://141026]=note: print w/replies, xml ) Need Help??


in reply to Re: Re (tilly) 1: Finding sum of all digits from 1 to 1 million.
in thread Finding sum of all digits from 1 to 1 million.

Off by one error again, your formula drops m from the answer. (And the obvious fix will need more cases if your range potentially includes negative integers.)

But still, you are essentially correct. After some wrapper logic, the problem really does boil down to being able to efficiently calculate the sum of the digits from 1 to n for any positive integer n.

  • Comment on Re (tilly) 3: Finding sum of all digits from 1 to 1 million.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found