Factorial using iterative method and Recursive method
Recursive Method
def Recursive(n):
if n==1:
return 1
else:
return n*Recursive(n-1)
n=int(input("Enter a number "))
print(Recursive(n))
Iterative Method
def iterative(n):
fac=1
for i in range(n):
fac=fac*(i+1)
return fac
Comments
Post a Comment