OneCompiler

Python Program to Find the Factorial of a Number

255

Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n.

For example factorial of 6 is 65432*1 which is 720.

CODE:

Python 3 program to find

factorial of given number

def factorial(n):

# single line to find factorial
return 1 if (n==1 or n==0) else n * factorial(n - 1) 

Driver Code

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