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
Love it? Share it!

DevCanvas DevCanvas Logo

Online Editor with a collection of awesome frontend code and code snippets for developers of all levels.

Legal & Support

Stand with Palestine 🇵🇸! DO NOT BE SILENCED

© 2025 DevCanvas. All rights reserved.