Sponsored Reserved space — layout preview until AdSense is connected
easy +8 pts

Factorial (iterative)

Classic iterative multiplication.

Implement `factorial(n: int) -> int`. Return n! (the product 1 × 2 × … × n). `factorial(0) == 1`.

Constraints

0 ≤ n ≤ 20

Example

>>> factorial(5)
120
8 points ~8 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use a running product starting at 1, loop range(1, n+1).
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.
Sponsored Reserved space — layout preview until AdSense is connected