Back to course home
0% completed
1. Basic Sum
Problem Statement
Calculate the Sum of the First N
Natural Numbers Using a Recursive Approach.
The sum of first N natural numbers is equal to N + (N-1) + (N-2) + ... + (3) + (2) + (1). The following table shows a sample input/output description table:
Input (s) | Output (s) | Explanation |
---|---|---|
N = 5 | Sum = 15 | The first 5 natural numbers are 1, 2, 3, 4, and 5. The sum of these numbers is 1 + 2 + 3 + 4 + 5 = 15. |
N = 10 | Sum = 55 | The first 10 natural numbers are 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10. The sum of these numbers is 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55. |
N = 1 | Sum = 1 | The first natural number is 1. The sum of this number is 1. |
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
Mark as Completed
Table of Contents
Problem Statement
Try it yourself