Exercise: The Factorial

Create a function that calculates the factorial of a number.

Problem statement

In this challenge, you are required to implement the factorial() function. It takes an integer as a parameter and calculates its factorial. Python does have a built-in factorial function but you’ll be creating your own for practice. The factorial of a number n is its product with all the integers between 0 and n.

Get hands-on with 1400+ tech skills courses.