posted by Jane .
Is there a formula to sum the digits between two numbers?
eg. 1 to 20 = 1+2+3+4+5+6+7+8+9+1+0+1+1+1+2+1+3+1+4+1+5+1+6+1+7+1+8+1+9+2+0 = ??
I am looking for the numbers 1 to 2008 so I really need a formula!
Please help, thank you.
There must be such a formula, but it will depend upon how many digits are in the number, and what the initial digits are.
From n = 0 to 9, if n is the largest number, the sum of digits is
From n = 10 to 19, in n is the largest number and you include the sum for digits for 1 though 9, the sum is
45 + (n-9) + (n-10)(n-9)/2
For n = 20 to 29, the sum is
55 + 2(n-19) + (n-20)(n-19)/2
And it keeps getting messier.