Mathematics

Factorials Explained: Formula, Examples, and Uses

Understand n!, 0!, recursive growth, elementary counting uses, and the NumUtility factorial domain from 0 through 170. This guide explains the reasoning, not just the keystrokes.

Published · Updated · 6 min read

Definition and notation

For a positive integer n, factorial is the product n!=n×(n-1)×...×2×1. The domain of this elementary definition is the nonnegative integers. The exclamation mark is postfix notation: 5! means multiply the positive integers from five down to one. It is not punctuation and does not mean that every real number has a value under this calculator's factorial operation.

The special values are 0!=1 and 1!=1. Defining the empty product as one keeps counting formulas and the recurrence consistent. Factorials are always positive in this domain. They grow much faster than ordinary powers with a fixed exponent, so even modest inputs produce long results and quickly exceed common floating-point ranges.

Recursive relationship

The recurrence n!=n×(n-1)! holds for n≥1. Starting from 0!=1 gives 1!=1×1=1, 2!=2×1=2, and so forth. It allows one factorial to be checked against the preceding value. Conversely, n!/(n)= (n-1)! for positive n, provided the stored value has not overflowed or lost detail.

The recurrence also explains the zero case: 1!=1×0!, and because 1!=1, consistency requires 0!=1. It does not define a factorial for negative integers by continuing through multiplication, because the step at zero would require division by zero in the reverse direction. Specialized extensions use Gamma functions, but NumUtility does not implement them.

Three exact examples

Input: 5!. Rule: multiply all positive integers from 5 down to 1. Steps: 5×4×3×2×1. Result: 120. Verification: 5×4!=5×24=120.

Input: 0!. Rule: use the defined empty product and recurrence base. Steps: there are no positive factors to multiply, so the product identity is used. Result: 1. Verification: 1!=1×0!=1 remains true.

Input: 8!. Rule: use the recurrence or descending product. Steps: 8×7×6×5×4×3×2×1. Result: 40,320. Verification: 8×7!=8×5,040=40,320. Entering 8! in the calculator returns the same finite Number value.

Permutations and combinations

If n distinct objects are arranged in order, there are n! permutations because the first position has n choices, the second n-1, and so on. Choosing and ordering r objects uses n!/(n-r)! when 0≤r≤n. Choosing without order uses n!/[r!(n-r)!]. These formulas are basic mathematical examples, not dedicated functions in the NumUtility interface.

Directly computing large factorials inside a ratio can create enormous intermediate values even when the final combination is moderate. Cancellation or a specialized combinatorics algorithm is usually preferable. The calculator evaluates the numeric expression you type but does not promise exact integer digits beyond JavaScript's safe-integer range. It should not be used as an auditable combinatorics or probability engine for consequential decisions.

Valid and invalid operands

NumUtility accepts a factorial operand only when its evaluated value is a safe, nonnegative integer no greater than 170. Thus 5!, 0!, and (3+2)! work. Negative integers and ordinary decimals fail. The expressions (-3)! and 4.5! are outside the elementary domain. Although 3.0 mathematically equals an integer, a calculated Number that is exactly 3 passes the integer check.

Only one factorial mark is supported. Double factorial 7!! is a different mathematical operation and is rejected, as are subfactorials and multifactorials. The Gamma function can extend n! through Γ(n+1) for many noninteger values, but it has poles and conventions beyond this guide. Gamma is not a hidden fallback; an unsupported input returns an error.

Why the implemented maximum is 170

JavaScript Number has a largest finite magnitude of about 1.7976931348623157×10^308. The value 170! is about 7.257415615307994×10^306 and remains finite, while 171! is about 1.241×10^309 and would overflow to Infinity. The parser therefore rejects every factorial operand above 170 before multiplying.

Input: 170!. Rule: accept a whole number within 0–170. Steps: multiply iteratively from 2 through 170 using Number arithmetic. Result: approximately 7.257415615307994e306. Verification: it is below Number.MAX_VALUE. Input: 171!. Rule: enforce the explicit cap. Result: an error stating that factorial requires a whole number from 0 to 170; the tool does not display Infinity as an answer.

Exact integers and floating-point limits

Small factorials are exactly representable, but eventually factorial integers exceed Number.MAX_SAFE_INTEGER even while remaining finite. A Number may then preserve magnitude without preserving every integer digit. The formatted interface shows up to twelve significant digits. Therefore the 170! output is a numerical approximation of an exact integer, not a complete exact decimal expansion.

Do not copy the display into a context requiring every digit. Use an arbitrary-precision integer library or trusted symbolic system for exact large factorials. NumUtility's limit prevents overflow, not all rounding. The same caution applies to ratios of large factorials, where separately rounded intermediate values can reduce accuracy. State when an output is approximate.

Factorial in the expression grammar

Factorial binds to the primary immediately before it and precedes exponentiation. Hence 3!^2=(3!)²=36 and 2^3!=2^(3!)=64. A parenthesized expression can be factorialized, but the resulting value must meet the integer and range checks. Unary minus outside the operand gives -3!=-6, whereas (-3)! is invalid because the operand itself is negative.

Use parentheses to make intent visible and consult the order-of-operations guide for full associativity. The main scientific guide lists all supported functions and constants. Factorial calculations here are educational arithmetic; the tool does not implement Gamma, permutations, combinations, probability distributions, or cryptographic operations, and no such capability should be inferred from the exclamation mark.

Growth, cancellation, and interpretation

The ratio between consecutive factorials is n+1 because (n+1)!/n!=n+1. This increasing ratio explains the rapid growth: every new step multiplies the entire preceding product by a larger integer. For comparison, 10!=3,628,800, 20! is about 2.43×10^18, and 50! is about 3.04×10^64. A small change in n is therefore not a small additive change in output.

When factorials appear in a quotient, cancel symbolically before evaluating. The expression 100!/98! simplifies exactly to 100×99=9,900, avoiding two enormous rounded intermediate Numbers. Similarly, n!/[r!(n-r)!] can often be evaluated as a short product divided by r!. NumUtility does not simplify symbolically, so the user must enter the reduced numeric expression when exactness or overflow margin matters.

Factorial counts ordered arrangements only under stated assumptions: objects are distinct and all orderings are allowed. Repeated objects, restrictions, circular arrangements, or selections without order require adjusted formulas. A calculator cannot infer those conditions from n!. Treat the counting model as part of the problem and use the factorial value only after confirming that the arrangement rule fits.

Input: 10!/8!. Rule: cancel the shared descending product before numerical evaluation. Steps: 10!/(8!)=(10×9×8!)/8!=10×9. Result: 90. Verification: 10!=3,628,800 and 8!=40,320, whose quotient is 90. The simplified form is both clearer and less exposed to large-number rounding. This technique applies only when the factorial factors genuinely cancel across a product or quotient; it does not justify cancellation across addition or subtraction between separate expression terms at all. Keep every cancellation algebraically visible.

Frequently asked questions

Why is 0! equal to 1?

It is the empty product and makes the recurrence 1!=1×0! consistent.

Can NumUtility calculate a factorial of a decimal?

No. The operand must evaluate to a nonnegative whole number.

What is the largest supported factorial input?

The maximum is 170. A factorial of 171 would exceed JavaScript Number's finite range.

Is the displayed value of 170! exact to every digit?

No. It is a finite floating-point approximation shown to limited significant digits.

Does the calculator support Gamma or double factorial?

No. Gamma, double factorial, permutations, and combinations are not implemented.

Sources

References used to support definitions and interpretation in this guide.

  1. NIST DLMF §5.4 — Gamma Function and Factorial
  2. MDN — JavaScript Number