Search⌘ K
AI Features

Exercise: Factorial of a Number

Explore how to create a factorial function in Python by applying loops and conditionals. Understand the logic of factorial calculation, including handling negative inputs, and practice implementing algorithms based on core Python concepts learned so far.

Problem Statement

In this challenge, you must implement the factorial() function. It takes an integer as a parameter and calculates its factorial.

The factorial of a number, n, is its product with all the positive integers smaller than n.

factorial(n)=n(n1)(n2). ...