You all had this experience at least once. You have to calculate the sum of all numbers to n, so naturally you start counting and counting, starting all over again because you made a mistake and finally using a calculator to get the answer. Well I don’t want to ruin your day but you did everything wrong. There’s a much simpler way to do this. Here’s how:

Formula to calculate sum of all numbers from 0 to n:

$\frac{n\cdot (n+1)}{2}$This equation will output the sum of all natural numbers from to n. Just multiply the biggest numbers with the same number + 1 and then divide that by 2. That’s how you can get the sum.

But what if you want to calculate the sum of all number from let’s say 5 to 36. This time, we don’t start with 1 but the equation is similar.

$\frac{n\cdot (n+1)}{2}\u2013\frac{(k\u20131)\cdot k}{2}$This will output the sum of the numbers from k to n including k.#

Example:

Sum from all numbers from 1 to 64:

Sum from all numbers between 24 and 105:

$\frac{105\cdot (105+1)}{2}\u2013\frac{(35\u20131)\cdot 35}{2}=4970$As you can see it is much easier to use this formula than to go trough each number and it also takes less time! Are you interested in more? Click here!