Sum Till N - III
Given a positive integer N, return the sum of all integers from 1 to N using recursion.
Note:
A normal iterative or formula-based solution will pass the test cases, but the goal of this problem is to solve it using recursion and strengthen your understanding of recursive calls and base cases.
Example 1:
Input: N = 5
Output: 15
Explanation: The sum from 1 to 5 is 1 + 2 + 3 + 4 + 5 = 15.
Example 2:
Input: N = 100
Output: 5050
Explanation: The sum of all integers from 1 to 100 is 5050.
Now Your Turn!
Pick the correct output for the given inputInput: N = 15
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= N <= 100