python iterative and recursive program

 ITERATIVE AND  RECURSIVE  PROGRAM

n = int(input("Enter value : "))


def iterative(n):
    for i in range(n):
        fact=1      
        fact=fact*(i+1)
        return fact
    pass
n=int(input("Enter the number : "))
print(iterative(n))

def func(n):
    if n == 1:
        return 1
    else:
        return n * func(n - 1)


print("factorial number of ", func(n))




Comments

Post a Comment

Popular posts from this blog

python code