BetaUnder construction. Questions are being reviewed by teachers — enjoy the free practice in the meantime.
Python basics · Exercise
Factorial
Write a function factorial(n) that returns n factorial, written n!. 5! = 5 x 4 x 3 x 2 x 1 = 120. By definition, 0! = 1. Hint: Start with result = 1 and multiply it by every number from 2 up to n.