formula for sum of n numbers code example
Example 1: formula for sum of n numbers
Sum of the First n Natural Numbers. We prove the formula 1+ 2+ ... + n = n(n+1) / 2, for n a natural number
Example 2: sum of all n integers
Sum of n integers 1 + 2 + 3 + ... + n = n * (n + 1) / 2