Professional Documents
Culture Documents
Factorial
Factorial
Factorial
AIM:
ALGORITHM:
PSEUDOCODE:
START
DEF factorial (n)
IF n==1 or n==0 THEN
RETURN 1
ELSE
RETURN n*factorial(n-1)
END IF
READ n
DISPLAY factorial(n)
STOP
IMPLEMENTATION CODE:
def factorial(n):
if n==1 or n==0:
return n
else:
return n*factorial(n-1)
n=int(input("Enter a num"))
print(factorial(n))
OUTPUT:
CASE 1:
CASE 2:
CASE 3:
RESULT:
The Python Code for Find Factorial of a Number is Written and Executed Successfully.