🌐 EN

🔢 Factorial Calculator

Calculates n! (n factorial) exactly, with no rounding error, using JavaScript BigInt. n must be an integer between 0 and 5000.

Enter an integer from 0 to 5000. The result is shown as an exact integer.

Results
GUIDE

Learn more

01

What is a factorial (n!)?

A factorial is the product of all positive integers from 1 to n, defined as n! = 1 × 2 × 3 × ⋯ × n. For example, 5! = 1×2×3×4×5 = 120. By convention, 0! = 1. Factorials are a foundational tool across combinatorics (permutations and combinations), probability theory, and series expansions.
02

Why compute with BigInt?

JavaScript's regular Number type loses precision beyond 2⁵³-1 (about 9×10¹⁵). But n! blows past that value quickly as n grows — 18! is already about 6.4×10¹⁵. This calculator performs the multiplication using JavaScript's BigInt type, so even for large n the exact integer result is shown with no rounding error.
03

Reference values and the input cap

5! = 120, 10! = 3,628,800, 15! = 1,307,674,368,000, 20! = 2,432,902,008,176,640,000. The digit count grows extremely fast as n increases (100! has 158 digits, 1000! has 2,568 digits), so results get very long — input is capped at n ≤ 5000 to keep server/browser load reasonable.

Frequently asked questions

Why is the maximum n capped at 5000?
As n grows, the digit count of n! grows exponentially (5000! has about 16,326 digits), which also grows the compute and rendering resources needed. The 5000 cap prevents excessive resource use while still covering nearly all practical use cases.
Why is 0! equal to 1?
0! is defined as 1 by mathematical convention. This matches the combinatorial interpretation that there is exactly one way to arrange zero items, and it keeps the recursive definition n! = n × (n-1)! consistent even at n=1.
What happens if I enter a negative number or a decimal?
Factorial is only defined for non-negative integers, so entering a negative number, decimal, or non-numeric text shows an error message. (The Gamma function extends factorial to most real and complex numbers except negative integers, but this calculator only handles integer factorials.)