Sum of Integers from 1 to n
In this lesson, we will learn how to compute the 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:
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:
The sum of all numbers up to a number is equal to the sum of that number and the sum of all the numbers before it. It can be seen as follows:
...
Access this course and 1400+ top-rated courses and projects.