Factorial Calculator
Advanced
Welcome to the Factorial Factorium! π
In this challenge, you're going to build a magic factorial calculator! π§ββοΈ
A factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example:
0! = 1(by definition)1! = 12! = 2 Γ 1 = 23! = 3 Γ 2 Γ 1 = 64! = 4 Γ 3 Γ 2 Γ 1 = 24
Your mission, should you choose to accept it, is to implement a function that calculates the factorial of a given number n.
Examples:
factorial(0) # returns 1 factorial(1) # returns 1 factorial(3) # returns 6 factorial(5) # returns 120
Let's start coding and unveil the magic of factorials! π
Inputs
Arg 1:
0Expected Output
1Actual Output