Editor settings

General settings

Save settings

Learn to program with Python

Factorialize a number #

Write a function factorial(n) that takes a non-negative integer n as input and returns the factorial of that number.

The factorial of a number n is the product of all positive integers from 1 to n. For example, a factorial of the number 5 is equal to 1 x 2 x 3 x 4 x 5, which is 120. Note that the factorial of the number 0 is aways 1.


Tests #

  • factorial(5) should return 120
  • factorial(0) should return 1
  • factorial(10) should return 3628800
Output will be displayed here