What is the sum of digits in the numbers 1 to 2010?

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
4 replies · 4K views
K Sengupta
Messages
113
Reaction score
0
Determine the sum of all the digits in the positive integers from 1 to 2010 inclusively.
 
Mathematics news on Phys.org
42.

It's the answer to everything.
 
Wouldn't that get you the sum of all the numbers, not the sum of the digits?
 
0->9 : (0..9) = 45
10->19 : 10*1*(0..9) = 450
20->29 : 10*2*(0..9) = 900
30->39: 10*3*(0..9) = 1350
...
2000-2009 : 10*200*(0..9) = 90000

+ 1
...


10*(1..200) + 201*(0..9) + 1 = 201000 + 9045 + 1 = 210046 digits from 1 to 2010