Sum of Integers from 1 to n

What does the sum of integers from 1 to n mean?

Natural numbers are positive numbers starting from 1. These can be written as:

1,2,3,4,5,6,7,8,9,10......1,2,3,4,5,6,7,8,9,10......

We want to write a program that takes a number and sums up all the numbers from 1 until that number.

Below is a visual to help you understand:

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.