Factorial Program in Python

 Factorial Program



Sample Input output

input=5

output=120

case=2

input=10

output=3628800


CODE:

def factorial(n):

    return 1 if (n==1 or n==0) else n*factorial(n-1)

num=int(input())

print("Factorial of",num,"is",factorial(num))


OUTPUT:





Try it Yourself ( our new feature )

Click on the "Try it Yourself" button to see how it works.

Blog

Post a Comment

Previous Post Next Post