Sum of N Natural Numbers

00:00
Easyloopsbasicmath

Given a positive integer n, calculate the sum of all natural numbers from 1 up to n inclusive.

Your task is to implement a function that computes this sum. While there are multiple ways to solve this (e.g., using a loop or the mathematical formula), try to implement it using a loop structure as discussed in the article.

Examples

Input → 1
Output → 1
Explanation:

The sum of the first 1 natural number is 1.

Input → 5
Output → 15
Explanation:

1 + 2 + 3 + 4 + 5 = 15.

Input → 10
Output → 55
Explanation:

The sum of numbers from 1 to 10 is 55.