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! = 1
  • 2! = 2 Γ— 1 = 2
  • 3! = 3 Γ— 2 Γ— 1 = 6
  • 4! = 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! 🌟

Geek
Inputs

Arg 1:

0
Expected Output
1
Actual Output
Factorial Calculator [advanced] | Coding for Kids