solulubeta
Sign in
Recursion & Memo / See it, then write it
01.05 · Problem

Sum From 1 to N

Easy Shrink by n − 1 Pro

Return 1 + 2 + … + n. Use recursion, not a loop or the formula.

Examples

Example 1

Input:  n = 4
Output: 10

1 + 2 + 3 + 4.

solulu Pro

Continue this problem with Pro

Inside: step-by-step hints · 9 hidden tests · reference solutions · code editor.

Lifetime ₹1,999 ₹999 · Launch offer
Mark this problem as solved when you are finished.

Item 5 of 44 · updated 2026-10-13