Factorial Calculator
Calculate factorials from 0! to 5000! locally. See digit counts and product steps, share inputs, and export every digit with versioned JSON or CSV results.
Enter values to calculate.
Trust summary CVP VERIFIED · CVP protocol 1.0.0-proposed · Core assurance
- Input interpretation
- Enter values to calculate.
- Result
- —
- Assurance
- Core
- Declared partition coverage
- PASS · 2/2 declared partitions (factorial, invalid-domain) · Matrix
- Numerical scope
- Exact decimal-string identity vs Python math.factorial on the 23 published tabulated vectors (named 0,1,5,10,20,100,5000 plus 16 seeded n in 0–4999). 5000! is verified as the full 16,326-digit value and as SHA-256 of those ASCII digits. This is not a whole-domain proof beyond the published table.
- Known limitations
- Ordinary factorial0≤n≤5000; exact product of normalized integer; matching n/nInput, bounded digits-only strings. Complete result metadata/types and truncated scientific preview; O3 tabulated exact checks23 cases, exhaustive5001 CPython audit recorded separately.
- Core CVP does not include live graph, viewport, or pointer interaction.
- Model
- n! for an integer n satisfying 0 ≤ n ≤ 5000, with optional product expansion, scientific notation for long integers, and digit count.
- Scope
- n is an integer satisfying 0 ≤ n ≤ 5000.
- Verification
- Engine tested · Source checked · v1.0.4 · CVP VERIFIED · CVP protocol 1.0.0-proposed · Core assurance· View Manifest · CVP overview · Specification
- Versions
- Calculation 1.0.4 · CVP protocol 1.0.0-proposed · Evidence 2026-10-20.factorial-complete-contract-v3
- Verification revision
- 2026-10-20.factorial-complete-contract-v3 · 19/19 property · digest 9ad5f31d8553
- Legacy regression
- 24/24 tests · Production surface contract 6/6
- Trust layers
- Verification VERIFIED · Production CURRENT · Overall CVP state: VERIFIED under CVP 1.0.0-proposed
- Reference
- O1 model · O3 expected_values · O3 numerical_behavior · O2 expected_values · O2 numerical_behavior
- Interfaces
- PASS · UI (SSR) / REST / MCP
- Supplemental domain review
- Not performed
- Named expert review
- Not performed
- CVP suite
- 6/6 golden · 7/7 CVP boundary · 6/6 invalid · 19/19 property · 5/5 metamorphic · 23/23 O3 · 1/1 cross-interface · 6/6 CVP contract · Manifest
- Sources
- NIST Digital Library of Mathematical Functions, Chapter 5
- NIST DLMF §5.4
- CalculatorX mathematical conventions
- Evidence
- 8 legacy golden · 7 legacy boundary · legacy regression suite · 6/6 oracle-backed golden · 6/6 invalid · Artifact integrity PASS
- Semantic contract
- PASS
Full verification
Formulas
Core equations used by this calculator.
How to use
Enter a non-negative integer n
Whole numbers only. The published domain is 0 ≤ n ≤ 5000. Fractions and negatives are not defined for ordinary factorial.
Calculate
Read n!, the product expansion when n is small, and — for results longer than 30 digits — scientific notation plus the exact digit count.
Use the count
For distinct items, n! is the number of different orderings (permutations).
Example calculations
Common configurations with formula and result.
Five factorial
Classic homework check
Ten factorial
Expansion to 3.6 million
Zero factorial
Empty product / one empty arrangement
One hundred factorial
Digit-count check at a large exact integer
Word with unique letters
8 distinct letters → arrangements
Word with a repeated letter
7 letters, one letter twice
Common factorial values
Common values at a glance.
| n | n! | Expansion |
|---|---|---|
| 0 | 1 | by definition |
| 1 | 1 | 1 |
| 2 | 2 | 2 × 1 |
| 3 | 6 | 3 × 2 × 1 |
| 4 | 24 | 4 × 3 × 2 × 1 |
| 5 | 120 | 5 × 4 × 3 × 2 × 1 |
| 6 | 720 | 6 × … × 1 |
| 7 | 5,040 | 7 × … × 1 |
| 8 | 40,320 | 8 × … × 1 |
| 9 | 362,880 | 9 × … × 1 |
| 10 | 3,628,800 | 10 × … × 1 |
| 12 | 479,001,600 | 12 × … × 1 |
| 15 | 1,307,674,368,000 | 15 × … × 1 |
| 20 | 2,432,902,008,176,640,000 | 20 × … × 1 |
Factorial calculator specification
Version 1.0.4 · Engine tested
- Engine tested 24/24 tests · Production surface contract 6/6
- Named expert review Not performed
- Calculation version 1.0.4
- Definition
- The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 through n. By definition 0! = 1. Factorials count ordered arrangements (permutations) of n distinct objects and appear in combinations, series, and probability.
- What it calculates
- n! for an integer n satisfying 0 ≤ n ≤ 5000, with optional product expansion, scientific notation for long integers, and digit count.
- Inputs
- Integer n with 0 ≤ n ≤ 5000
- Outputs
- Exact n! (grouped digits when ≤ 30 digits; scientific form when longer)
- Product expansion for small n
- Digit count of the exact integer
- Formula
n! = n×(n−1)×…×1; 0! = 1- Assumptions
- n is an integer satisfying 0 ≤ n ≤ 5000.
- Ordinary (single) factorial only — not multifactorial and not the real Gamma function for non-integers.
- Units
- Dimensionless (counting / combinatorial)
- Boundary conditions
- Missing n → MISSING_REQUIRED_INPUT
- Non-numeric n → INVALID_NUMBER
- Non-integer n (for example 5.5) → INVALID_NUMBER
- n < 0 → VALUE_MUST_BE_NON_NEGATIVE
- n > 5000 → VALUE_ABOVE_MAX
- Numerical precision
- Interactive calculation uses exact BigInt locally: n! = 1×2×…×n, with 0! = 1 by definition.
- Shareable URLs (?n=5 or ?nInput=5) are server-rendered with the same deterministic engine so crawlers and no-JS clients see the same result.
- REST and SSR return { n, value, exact, digits, expansion, scientific, max_n }. value is a JSON number when it fits in IEEE-754 safe integers, otherwise the exact decimal string.
- On-page display: exact grouped integer when digits ≤ 30; scientific notation plus digit count when digits > 30. Scientific notation is not shown for short values such as 5! = 120.
- Example
- 5! = 120; 10! = 3,628,800; 100! has 158 digits; 5000! has 16,326 digits
- Validation cases
12 published on this page · 24/24 tests · Production surface contract 6/6 · View evidence
- n=0 → 1
- n=1 → 1
- n=5 → 120
- n=10 → 3628800
- n=20 → 2432902008176640000
- n=100 → 158 digits
- n=1000 → 2568 digits
- n=5000 → 16326 digits
- n=-1 → error VALUE_MUST_BE_NON_NEGATIVE
- n=5.5 → error INVALID_NUMBER
- n=5001 → error VALUE_ABOVE_MAX
- empty n → error MISSING_REQUIRED_INPUT
- Sources
- NIST Digital Library of Mathematical Functions, Chapter 5 — Gamma FunctionSupports: Ordinary factorial of a nonnegative integer; n! = Γ(n+1)
- NIST DLMF §5.4 — Special values and extremaSupports: n! = Γ(n+1), including 0! = 1. This calculator publishes ordinary factorial only; non-integer Gamma values are out of scope.
- CalculatorX mathematical conventions — Domain 0 ≤ n ≤ 5000; exact BigInt n!Supports: Matches the on-page contract. Permutation count P(n,n)=n! is an interpretation, not a second engine.
- NIST Digital Library of Mathematical Functions, Chapter 5 — Gamma Function
- Calculation version
- 1.0.4
Background
Interpretation and common distinctions.
What does this factorial calculator compute?
The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 through n. By definition 0! = 1. Factorials count ordered arrangements (permutations) of n distinct objects and appear in combinations, series, and probability.
The published formula or method is n! = n×(n−1)×…×1; 0! = 1. The following references support the stated mathematics or method:
- NIST DLMF §5.4 — Gamma Function Special Values: The gamma/factorial relation at nonnegative integer arguments.
Which inputs and limits should you check?
Follow the input domain, units, branch or solve direction, and rounding policy in the specification. Preserve exact outputs and any additional candidates or warnings.
The worked example uses Classic homework check with 5! = 5×4×3×2×1. Compare it with the Example calculations and the complete result for the same inputs.
How can you verify and cite this result?
CalculatorX is responsible for this page. The mathematical references above explain the model; implementation checks and their scope are documented separately in the math.factorial v1.0.4 Evidence and capability contract. Read the displayed verification and production state together with the specification's numerical limits.
Use the clean calculator URL to cite the tool. A shared input link identifies a particular calculation. Content updates, numerical verification, and domain reviews have separate dates and scopes.
What is a factorial?
For a non-negative integer n,
n! = n × (n−1) × (n−2) × ⋯ × 1
with the special case
0! = 1.
Equivalently, n! = n × (n−1)! for n ≥ 1.
Example:
10! = 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 3,628,800.
Related mathematics
The Gamma function extends factorial off the nonnegative integers via n! = Gamma(n+1) (NIST DLMF §5.4). This calculator publishes ordinary factorial only: integers satisfying 0 ≤ n ≤ 5000. Inputs such as 4.5! are out of scope.
Where factorials show up
- Counting permutations and combinations
- Probability and binomial coefficients binomnk = n! / (k!(n−k)!)
- Taylor series and many algebra/discrete-math identities
- Computer science (complexity of brute-force orderings)
Supported and not supported
Supported
- Ordinary factorial n! for integers 0 ≤ n ≤ 5000
- Exact BigInt integer, product expansion for small n, digit count, and scientific notation when digits > 30
- Share URL, REST, and MCP via
math.factorial
Not supported
- Multifactorial (n!!, n!!!)
- Gamma Gamma(n+1) for non-integers
- n < 0 or n > 5000
Agent / API notes
Capability id: math.factorial · tool id: factorial · pin calculation_version: 1.0.4.
Stable error codes: MISSING_REQUIRED_INPUT, INVALID_NUMBER, VALUE_MUST_BE_NON_NEGATIVE, VALUE_ABOVE_MAX.
Aliases: n (canonical) and nInput (share URL / form id). Interactive calculation uses exact BigInt locally; shareable URLs are server-rendered with the same engine.
Exact inputs, readable previews and complete exports
Enter an integer from 0 through 5000. Decimal digit strings (optional minus sign and surrounding whitespace) are accepted; scientific notation, fractions, hexadecimal and strings longer than 64 trimmed characters are rejected. nInput is an alias of n; both must agree. Explicit empty inputs remain empty in shared links. Unknown machine input fields are rejected. JSON number tokens are normalized to binary64 before integer validation: ordinary finite rounding is permitted, while nonzero tokens that underflow to zero are rejected as NUMERIC_UNDERFLOW. “Exact” refers to the factorial of that normalized integer, not arbitrary source-decimal precision.
The integer product uses BigInt with no rounding. Above 30 digits the main value is a truncated 12-leading-digit scientific preview. Copy JSON and Download CSV include the complete factorial_output: n, exact decimal digits, safe-number-or-string value, digit count, expansion, scientific preview and maximum n. The 5000! export retains all 16,326 digits. The 5000 bound limits work and output size; it is not a mathematical limit.
Interactive calculation runs locally without an account. Parameterized links reach the server for rendering; REST and MCP send inputs for execution. Analytics may load under site configuration. These paths do not establish a zero-logging, retention, deletion or processing-region guarantee. A versioned share link identifies the requested version; an older version link can show the current engine with a notice rather than replaying a historical runtime.
Related tools
Other calculators in this family: Arithmetic Sequence Calculator, Fibonacci Calculator, GCF Calculator, Geometric Sequence Calculator, LCM Calculator, Modular Inverse Calculator, Modulo Calculator, Permutation Combination Calculator . Explore all Number Theory & Discrete Math.
Frequently asked questions
Key distinctions behind the calculation.
What is a factorial?
n! multiplies n by every smaller positive integer down to 1. Example: 5! = 5×4×3×2×1 = 120.
Why is 0! equal to 1?
By definition the empty product is 1, and it keeps the recurrence n! = n×(n−1)! consistent at n = 1. There is also exactly one way to arrange an empty set.
What values of n are allowed?
Integers satisfying 0 ≤ n ≤ 5000. Negative factorials and non-integer gamma values are outside this calculator.
How many ways can n distinct objects be arranged?
There are n! permutations. For 4 distinct items, 4! = 24 orders.
What if some items are identical?
Divide by the factorial of each repeated count. For a 7-letter word with two identical letters: 7!/2!. Two different pairs of repeats: n!/(2!×2!).
Why does the answer switch to scientific notation?
Only when n! has more than 30 digits. Smaller values stay as the exact integer (with a digit count). The tool still knows the exact integer; large results show a compact ×10ⁿ form plus how many digits that integer has.
Is there a maximum n?
Yes. n must satisfy 0 ≤ n ≤ 5000 so the page stays responsive. 5000! is an exact integer with 16,326 digits.