Showing posts with label recursion. Show all posts
Showing posts with label recursion. Show all posts

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)