0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
A factorial is the product (multiplication result) of all positive integers less than or equal to a given number. For example:
1! = 1 = 1
2! = 2 * 1 = 2
3! = 3 * 2 * 1 = 6
4! = 4 * 3 * 2 * 1 = 24
5! = 5 * 4 * 3 * 2 * 1 = 120
There's also a special case for zero:
0! = 1
It's just 1
by definition of the fancy math folks (ivory tower types).
Complete the factorial()
function. It should return the factorial of a given number.
In mathematics, the !
symbol denotes a factorial, but is not a valid Python Factorial operator. Use a loop and multiplication to compute the proper result.
Focus Editor
Alt+Shift+]
Next Tab
Alt+Shift+[
Become a member to Submit
Become a member to Run
Become a member to view solution