BasicsChallenge 6 of 34

Factorial

Write factorial(n) that returns n! — the product of every integer from 1 to n. factorial(0) is 1. Solve it with a or with , your choice.

Examples
factorial(5) → 120
Exercise

Factorial

3 checks
def factorial(n):
    ...


print(factorial(5))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.