I am looking for an equation that will sum the number of digits of a number i.e. for 4, 1 + 2 +3 + 4 = 10 for 5, 1 +2 +3 + 4 + 5 = 15. I want to replace 4 and 5 with a variable so that any number can be added up to give an answer.
So, you want the sum 1+2+3+...+(n-1)+n?
Here lies the reader who will never open this book. He is forever dead.
Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment
Welcome to the forum.
Known as the sum of counting numbers (or triangle numbers) formula, what you want is:
The diagram below shows where it comes from.
If you stack up n then n-1, then n-2 ....... 3, 2, 1 squares it makes a sort of right angled triangle.
Then make the same again but turn this stack up-side-down and slot it into the triangle to make a rectangle.
The rectangle is 'n' high and n+1 wide so its area is n(n+1).
But we've made twice the sum you want, so divide by 2.
Last edited by bob bundy (2013-12-16 09:39:16)
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei