Ex-1 Factorial
Ex-1 Factorial
DATE FACTORIAL
19/07/24
AIM:
To implement the Python program to find the factorial of number using the three
methods such that :-
Looping method
Recursion method
Stiriling’s approximation
ALGORITHM:
# method 1: Looping :
# method 2 : Recursion :
#Factorial
#Method 1 Looping/Iteration
#Method 2: Recursion
lb=(1/(12*N)+1)
rb=1/(12*N)
D=rb-lb
LBDA=lb+D
Nfact=(math.sqrt((2*3.14)*N)*(N**N)*(math.exp(-N))*(math.exp(LBDA)))
#where 1/(12*N+1)< lambda <1/(12*N)
print("Factorial of N:",Nfact)
def factorial(N):
if N==0:
return 1
return N*factorial(N-1)
print("Actual Factorial:",factorial(N))
OUTPUT :
The Python program to find the factorial of the given number using the
above 3 approaches have been executed and error approximation has been
done.