Easy · Math

Factorial number

Given an integer n ≤ 20, return n!, the product of the integers 1 through n (with 0! = 1), or 0 when n is negative.

Examples

Example 1

n = 5

Output: 5! = 120

Example 2

n = 0

Output: 0! = 1

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Math problems