Grokking the Art of Recursion for Coding Interviews
Ask Author
Back to course home

0% completed

2. Factorial
Table of Contents

Problem Statement

Try it yourself

Problem Statement

Calculate the Factorial of a Positive Number Using Recursion.

The factorial of a non-negative integer N, denoted as N!, is the product of all positive integers less than or equal to N. The factorial of 0 is defined as 1.

Here is what the example input/output looks like:

InputExpected OutputExplanation
Number = 5Factorial = 120The factorial of 5 is calculated as 5 _ 4 _ 3 _ 2 _ 1 = 120.
Number = 7Factorial = 5040The factorial of 7 is calculated as 7 _ 6 _ 5 _ 4 _ 3 _ 2 _ 1 = 5040.
Number = 1Factorial = 1The factorial of 1 is 1 itself.

Try it yourself

Try solving this question here:

Python3
Python3

. . . .
Mark as Completed

Table of Contents

Problem Statement

Try it yourself