Sum of Integers from 1 to n
In this lesson, we will learn how to compute the sum of integers from 1 to n using recursion.
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 particular number and sums up all the numbers from 1 up until that number.
The illustration below explains the concept to help you understand.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.