- 1

What is output of following code?

def func(n): if(n==1): return 1; else: return (n+func(n-1)) print(func(4))

9th Nov 2021, 8:31 AM
Web Sad
Web Sad - avatar
3 ответов
+ 6
How about running it in the code editor??
9th Nov 2021, 9:17 AM
MATOVU CALEB
MATOVU CALEB - avatar
+ 2
The answer is 10, but the question you should ask is why?
9th Nov 2021, 9:29 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
It is a recursive function return sum of numbers upto given range
9th Nov 2021, 11:12 AM
sree harsha
sree harsha - avatar