DS160123 What is the output of the below code?

Date:- 21/02/2023
def fun(n,res=1):
if(n<=0):
return res
return fun(n-1,n*res)
print(fun(5))
A) 15 (B) . (C) 1 (D)120

2 Likes

D will be Answer for this

2 Likes

Function is calculating factorial using recursion.
So, 5! = 120

3 Likes

@kharshavardhan31
Yes correct :100: keep it up

2 Likes