K Sengupta Messages 113 Reaction score 0 Thread starter Jan 16, 2010 #1 Determine the sum of all the digits in the positive integers from 1 to 2010 inclusively.
Char. Limit Gold Member Messages 1,222 Reaction score 23 Jan 16, 2010 #2 42. It's the answer to everything.
Char. Limit Gold Member Messages 1,222 Reaction score 23 Jan 16, 2010 #4 Wouldn't that get you the sum of all the numbers, not the sum of the digits?
cronxeh Gold Member Messages 1,006 Reaction score 11 Jan 16, 2010 #5 Spoiler 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
Spoiler 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