Write a programExercise 1/4Basic10 XP
The sum from 1 to n
Task
Write a recursive function sucet(n) that returns the sum 1 + 2 + … + n for a non-negative whole n. For n = 0 the sum is 0.
Do not use loops - the function must call itself.
Examples
Call
print(sucet(4))
Expected output
10
Rules
Solve it with recursion - no
fororwhileloops.
After you submit, 4 hidden tests will also check your solution: n = 0, n = 1, n = 100, n = 500.
You need to know
Python starts the first time you run code.
Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.
Input (stdin)
Each line = one call to input().
Output
Hints
Try it yourself first. Each hint reveals a little more - and lowers the reward a little.
Signed out, hints are free - but no XP is awarded either.
Solution
The solution unlocks after the last hint.