Functions - recursion - Factorial of a number

# Functions - recursion, Factorial of a number

def fnfact(n):
    if (n==0):
        return 1
    else:
        fact = n * fnfact(n-1)
   
    return fact

num = int(input("Enter number :"))
f = fnfact(num)
print("Factorial of", num, "is", f)

No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu