Calculate the factorial of a number using iterative method -Python

Shared by: devcanvas

python

1
# Iterative method to calculate factorial
2
def factorial_iterative(n):
3
    result = 1
4
    for i in range(1, n + 1):
5
        result *= i
6
    return result