Factorial calculator

Enter a natural number n. The factorial n! is the product 1·2·…·n. For n = 5 the result is 120; for n = 0 it is 1 (empty product); for n = 7 it is 5040. The calculator uses n = max(0, ⌊x⌋): decimals go down, and a negative n yields 0! = 1. It does not compute the gamma function or Stirling’s approximation. For n ≥ 171 it reports a float range error.

Inputs

Result

Enter n, for example 5.

Factorial is defined for a whole n, n ≥ 0. The calculator uses the integer part, then max with zero. A negative n is replaced by 0, so the result is 0! = 1. There is no Stirling approximation and no gamma function here.

How it works

How 5! is computed
n5
1·2·…·n5!
n!120

The factorial n! is the product of the natural numbers from 1 to n: n! = 1·2·…·n for integer n ≥ 1, and 0! = 1 by the empty-product convention. 5! = 1·2·3·4·5 = 120. 7! = 5040. The exclamation mark is this operation, not a shout. The mathematical model is the factorial of a natural number, matching combinatorics textbooks and NIST DLMF §5.2 (the identity n! = Γ(n+1) for n ∈ ℕ₀ — context only, not a computed value here).

The calculator uses the number you enter in field n. The calculator sets n = max(0, ⌊a⌋): floor toward −∞, then clamp to non-negative. Then it multiplies r = 1 from i = 2 to n. So 5.7 is counted as 5! = 120, and −3 is replaced by 0, so the result is 0! = 1. Comma and period are equivalent.

The result panel shows n!, the floored n, the raw input, the product 1·2·…·n, (n−1)!, and the recurrence n · (n−1)!. A bar diagram (for moderate n) draws 0!…n! on a log height scale. Worked examples: 5 → 120, 0 → 1, 7 → 5040, 10 → 3,628,800; 5.7 → 120; −3 → 1.

The same product appears as P(n) on the permutations page, but the meaning differs: here you ask for the factorial as an operation, not for an arrangement count. For negative n this page replaces n with 0 (result 0! = 1), while the permutations page returns 0. The calculator does not evaluate Stirling’s formula, the gamma function, or a fractional factorial.

Definition sources: Concrete Mathematics (Graham, Knuth, Patashnik); Brualdi — Introductory Combinatorics; MathWorld — Factorial; NIST DLMF §5.2; Wikipedia — Factorial. Educational tool.

Formula

n! = 1 · 2 · … · n for integer n ≥ 1, and 0! = 1.

Recurrence: n! = n · (n − 1)! with 0! = 1.

Computation: n = max(0, ⌊a⌋), then the product of consecutive integers. Symbol a is the “n (natural number)” field. Mathematical model: factorial of a natural number (Concrete Mathematics; NIST DLMF §5.2 — Γ context).

Theory, 0!, and growth of n!

Definition

Let n be a non-negative integer (n ∈ ℕ₀). The factorial n! is the product 1·2·…·n when n ≥ 1, and the value 1 when n = 0. Equivalently: 0! := 1 and n! := n·(n−1)! for n ≥ 1. This is standard school algebra and enumerative combinatorics: Graham, Knuth, Patashnik, Concrete Mathematics; Brualdi, Introductory Combinatorics; MathWorld (Factorial); NIST Digital Library of Mathematical Functions, §5.2 (factorial / gamma). The identity n! = Γ(n+1) links the integer factorial to the gamma function for n ∈ ℕ₀ — this calculator does not evaluate Γ, but it respects the integer values from the product definition.

Computation on this page: n = max(0, ⌊a⌋); result = the product of the integers from 2 to n. For n = 0 and n = 1 the loop does not multiply, so r stays 1. A negative input, after rounding down and clamping to zero, becomes 0, so the result is 0! = 1. The calculator does not return factorials of negative integers (where Γ has poles) or fractional factorials.

The result is only the integer n! (in the browser’s floating-point arithmetic). The panel does not emit a symbolic expansion, does not use big-integer arithmetic, and does not apply Stirling’s approximation.

Historical and conceptual context

Products of successive natural numbers appear when counting arrangements (permutations) from ancient Indian texts through medieval multiplication rules. Modern notation n! was popularized by Christian Kramp (1808); the link to the gamma function (Euler, Legendre) and Stirling’s approximation for large n were systematized in analysis. NIST DLMF §5.2 codifies n! = Γ(n+1) on the naturals. In classical probability, n! enters denominators of uniform models on Sₙ; in series, it appears in eˣ = Σ xᵏ/k!.

Conceptually separate: (1) the integer factorial as a product — this page; (2) the permutation count P(n) = n! — same number, different meaning; (3) k-permutations / variations V(n,k) = n!/(n−k)!; (4) combinations C(n,k) = n!/(k!(n−k)!); (5) Stirling and gamma — context, not panel output. The permutations sibling shares the product but returns 0 for negatives instead of replacing n with 0.

In computer science, n! appears in the complexity of generating all orders and in comparison-sort lower bounds (log₂(n!)). In practice, 20! already exceeds the exactly representable integers — hence the panel warning for large n.

Formal properties

Mathematical domain: n ∈ ℕ₀. Codomain: {1, 1, 2, 6, 24, 120, 720, …}. Recurrence: 0! = 1, n! = n·(n−1)! for n ≥ 1. Monotonicity: for n ≥ 2, n! > (n−1)!.

Identities: P(n) = n!; V(n,n) = n!; C(n,k)·k! = P(n,k). Stirling’s formula n! ∼ √(2πn)·(n/e)ⁿ describes growth (Concrete Mathematics; Feller) — this calculator does not apply it. Gamma: Γ(n+1) = n! for n ∈ ℕ₀ (NIST DLMF §5.2); for non-positive integers Γ has poles, so a “negative factorial” does not exist in ℝ.

In this calculator the practical domain includes non-integer inputs (floor) and negatives replaced by 0. That is a convention of this calculator, not a theorem about the Γ function.

Full derivation

Step 1 (product definition). For n ≥ 1 set n! := 1·2·…·n. For n = 0 set 0! := 1 (empty product).

Step 2 (recurrence). For n ≥ 1 factor out n: n! = n·(n−1)!. The base 0! = 1 closes the induction.

Step 3 (computation). After n = max(0, ⌊a⌋) set r = 1 and multiply by 2, 3, …, n. When n ∈ {0,1}, the loop does not run and r = 1.

Step 4 (example). For a = 5: n = 5, r = 2·3·4·5 = 120. For a = 5.7: ⌊5.7⌋ = 5 → 120. For a = −3: max(0,−3) = 0 → 1.

Step 5 (link to P(n)). The number of linear arrangements of n distinct objects is n! (multiplication rule n·(n−1)·…·1). Hence P(n) = n! for n ≥ 0 — the same number, different narrative stress on the permutations page.

Special cases

0! = 1 and 1! = 1 — same value, different reading (empty product vs single factor). 2! = 2. 3! = 6. 4! = 24. 5! = 120. 6! = 720. 7! = 5040. 10! = 3,628,800.

Input 5.7 → 120. Input −1 → 1 on this page (replaced by 0). A fractional factorial (e.g. 1.5!) needs Γ — not available here. Stirling is not shown as a result.

When n is very large, the result first loses integer bit precision (above 2⁵³), and above 170! it would exceed the floating-point range — for n ≥ 171 the calculator reports an error. That is a floating-point arithmetic limit, not a limit of the definition of n!.

Numerical notes

Computation: n = max(0, ⌊a⌋); n! = 1·2·…·n. Multiplication is exact for integer n! while the value stays within the exactly representable integers, that is through 18!. From 19! the panel shows the result as an approximation ≈ m × 10^e, and n ≥ 171 gives an error message.

The calculator accepts a comma or a period as the decimal separator. The calculator does not use big-integer arithmetic or arbitrary-precision libraries. Sibling contrast: the permutations page returns 0 for negatives; here a negative yields 1 after being replaced by 0.

In teaching practice, distinguish the mathematical formula from floating-point limits: this calculator shows the browser’s computed result, not a symbolic paper proof.

Related notions and sources

Related on CalcBoxer: permutations P(n) = n!, variations V(n,k), combinations C(n,k). Related in theory: the gamma function, Stirling’s formula, Stirling numbers, the series for eˣ.

Sources: Graham, Knuth, Patashnik — Concrete Mathematics; Brualdi — Introductory Combinatorics; NIST DLMF §5.2; MathWorld — Factorial; Wikipedia — Factorial; Kramp (1808) — n! notation. Educational tool.

How to use

  1. Enter n in the n field, for example 5.
  2. Click Calculate or wait for the live result. 5! = 120.
  3. Check the panel: n after floor and max, the product, (n−1)!, and the recurrence. The bar diagram shows 0!…n! for moderate n.
  4. Zero in the field gives 1. A negative n also gives 1 (replaced by 0). 7! = 5040. 10! = 3,628,800.
  5. The count of arrangements of n items is on the permutations page. Choosing k of n is on combinations. Here you compute the factorial itself.

Symbol glossary

n! = 1·2·…·n. 5! = 120. 0! = 1. 7! = 5040. Field silnia-a after floor and max(0, ·).

n!
Primary result — the factorial. 5! = 120. 0! = 1.
n
Argument after max(0, ⌊a⌋). Field silnia-a. 5.7 → 5.
0!
One, from the empty product. Not zero. That is why C(n,0) = 1.
(n−1)!
Previous factorial in the recurrence n! = n · (n−1)!.

Examples

Example 1

  • n = 5

120

What is 5!? 120.

Example 2

  • n = 0

1

What is 0!? 1.

Example 3

  • n = 7

5040

What is 7!? 5040.

Example 4

  • n = 10

3,628,800

What is 10!? 3,628,800.

Example 5

  • n = 5.7

120

What is the factorial of 5.7? 120 (⌊5.7⌋=5).

Example 6

  • n = −3

1

What is the factorial of −3? 1 (→ 0!).

Related calculators

Common questions

What is the factorial n!, and how does this calculator compute it?

The factorial n! is the product 1·2·…·n for integer n ≥ 1, and 0! = 1. The calculator uses the “n (natural number)” field: n = max(0, ⌊input⌋), then multiplies in a loop. It does not compute Stirling or the gamma function.

What is 5!?

The result is 120, because 1·2·3·4·5 = 120. That is the first example on this page — the same result after “Fill this example”.

Why is 0! = 1?

The empty product is taken as one. That keeps C(n,0) and V(n,0) equal to 1. It is a school and textbook convention, not a calculator glitch.

What happens with a negative n?

A negative input is replaced by n = 0 via max(0, ⌊x⌋), so the result is 0! = 1. On the permutations page a negative n returns 0 — a different convention.

Does 5.7 give a different factorial from 5?

No. The calculator uses the integer part toward −∞: ⌊5.7⌋ = 5, so the result is 5! = 120. The same holds for 5.2 and 5.9.

How is factorial different from a permutation P(n)?

For n ≥ 0 the number is the same: P(n) = n!. Here you see the product and the factorial operation. On the permutations page that same 5! = 120 is the count of arrangements of five items.

Does the calculator use Stirling or the gamma function?

No. It stays with the ordinary whole-number product in floating-point arithmetic. Stirling’s approximation and Γ(n+1) appear only as theory context — the panel does not evaluate them.

How fast does n! grow, and when does precision fail?

Each next n multiplies the result by n: 7! = 5040, 10! = 3,628,800. Above about 18!, floating-point arithmetic may lose integer exactness; from 19! the result is shown as ≈ m × 10^e, and n ≥ 171 gives a range error.

Do the currency and unit settings in the page header affect the result?

No. The result depends only on the entered n. The currency and unit settings in the page header do not affect this result.

What are 7! and 10!?

7! = 5040. 10! = 3,628,800. Those are examples 3 and 4 on this page.

How do I calculate the factorial n!?

Multiply the consecutive natural numbers from 1 to n. Formula: n! = 1 · 2 · … · n, and 0! = 1. Example: 5! = 120. Enter n in the calculator field.

What is 10!?

3,628,800. Enter n = 10. That is the fourth example on the page.

Does factorial work for fractions?

The classical factorial does not. This page takes the integer part toward −∞ (⌊x⌋), so 5.7 gives 5! = 120. The gamma function Γ(n+1) is not computed here.

Why does a negative n give 1 instead of an error?

The calculator maps a negative input to 0 via max(0, ⌊x⌋), so the result is 0! = 1. On the permutations page a negative n returns 0 — a different convention.

Up to which n does the calculator work?

Through n = 170 in float arithmetic. From about 19! the result may show as ≈ m × 10^e (loss of integer exactness). For n ≥ 171 a range error appears.

The result is n!: for n = 5 it is 120; for n = 0 it is 1. A negative n is replaced by 0, so the result is 0! = 1. Permutations and combinations are on neighboring pages.

Knowledge sources

The definition of n!, 0! = 1, and Γ context come from established mathematical sources.

Page updated November 3, 2026.