Define factorial(n) to return the product of every integer from 1 through n. The function must use an iterative approach and return 1 for the base case n = 0.
Function Contract
Input: a non-negative integer n.
Output: the integer value of n!.
Constraints
0 <= n <= 10^4
n is an integer
The input is non-negative
Function Signature
deffactorial(n):
Interviewer
Your question is Factorial Function in Python. Start with the requirements in the Question tab.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.