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:

n ( 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.

n ( n + 1 ) 2 ( k 1 ) k 2

This will output the sum of the numbers from k to n including k.#

Sum from all numbers from 1 to 64:

64 ( 64 + 1 ) 2 = 64 65 2 = 2080

Sum from all numbers between 24 and 105:

105 ( 105 + 1 ) 2 ( 35 1 ) 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!

Leave a Reply

Your email address will not be published. Required fields are marked *