Permutation calculator

Enter n. The result is the number of linear arrangements of n distinct items: P(n) = n! = P(n,n). With n = 5 you get 120; with n = 4 — 24; with n = 0 — 1. The calculator uses the integer part ⌊n⌋. A negative n returns 0. This is not a variation V(n,k) with k < n, not a combination, and not permutations with repetition — the result is a count only, with no list of arrangements.

Inputs

Result

Enter n, for example 5.

The calculator uses the integer part of n. A negative n returns 0. This is not a combination and not a variation with k smaller than n — here you arrange everyone: P(n) = P(n,n).

How it works

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

A permutation of an n-element set is a bijection of the set onto itself; in school and applied language it is one linear arrangement of n distinct objects. The number of such arrangements is P(n) = n! = 1·2·…·n for integer n ≥ 1, and P(0) = 1. Five different books on a shelf have 120 orders, because P(5) = 5! = 120. Four people in a queue have 24 line-ups. The symbols P(n) and n! are the same number; writing P(n,n) = n!/(n−n)! = n!/0! stresses that a full permutation is the special case of a k-permutation (variation) with k = n.

The formula follows the multiplication rule: the first seat has n choices, the second has n−1 remaining, …, the last has one. The product n·(n−1)·…·1 is exactly n!. Equivalently P(n) = n · P(n−1) with P(0) = 1. A combination C(n,k) ignores order; a variation V(n,k) = n!/(n−k)! lines up only k of n. This calculator counts only the full line-up: V(n,n).

The calculator uses the number you enter in the “n” field. The calculator takes n = ⌊a⌋: the integer part toward −∞. For n ≥ 0 it multiplies r = 1 from i = 2 through n; for n < 0 it returns 0. So 5.7 counts as P(5) = 120, and −3 returns 0 — unlike the factorial calculator, where a negative input may fall through to 0! = 1. Comma and period are equivalent. Header currency and unit labels do not enter the formula.

The result panel shows P(n), the floored n, the product 1·2·…·n, P(n−1), and the identity P(n,n) = n!. For moderate n a bar diagram draws P(0)…P(n) with log-scaled heights so the multiplication by successive integers is visible. Worked examples: P(5) = 120, P(4) = 24, P(0) = 1, P(6) = 720, P(10) = 3,628,800; negative n → 0.

The mathematical model is the classical count of permutations of a finite set (permutations of n distinct objects) from enumerative combinatorics. Brualdi, Stanley, and Concrete Mathematics (Graham, Knuth, Patashnik) treat n! as the number of linear orders. This calculator does not list permutations, does not count permutations with repetition (multinomials), and does not classify cycle types — it only evaluates n!.

Formula

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

Equivalently: P(n) = P(n,n) = n! / (n − n)! = n! / 0!.

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

The symbol n is the item count after floor (the “n” field). Mathematical model: number of permutations of n distinct objects (Brualdi; Stanley; Concrete Mathematics). Computation: product of consecutive integers for n ≥ 0; negative n → 0.

Theory, factorial, and P(n,n)

Definition

Let S be an n-element set (n ∈ ℕ₀). A permutation of S is a bijection π: S → S. Equivalently, when the elements of S are written as a sequence (x₁, …, xₙ) with no repeats, each such sequence is one permutation. The number of all permutations is |Sym(S)| = n!, where n! = 1·2·…·n for n ≥ 1 and 0! = 1 by the empty-product convention. In school notation and on this calculator we write P(n) = n!. The identity P(n,k) = n!/(n−k)! for 0 ≤ k ≤ n counts k-permutations (variations without repetition); when k = n we get P(n,n) = n!/0! = n!, so P(n) = P(n,n).

The definition is standard enumerative combinatorics: Brualdi, Introductory Combinatorics; Stanley, Enumerative Combinatorics, vol. 1; Graham, Knuth, Patashnik, Concrete Mathematics (factorial and counting chapters). MathWorld (Permutation) and Wikipedia (Permutation) state the same equality |Sₙ| = n! for the symmetric group. Computation here: n = ⌊a⌋; result = product 2…n when n ≥ 0, otherwise 0.

The calculator does not list permutations and does not classify cycles, transpositions, or the sign of a permutation (sgn). The result is only the cardinality of all linear arrangements — the integer P(n).

Historical and conceptual context

Counting arrangements appears in ancient Indian texts and in medieval writings on “orders of ranks.” Modern formalization ties permutations to the symmetric group Sₙ (Galois, Cauchy) and to the factorial as a counting function. Christian Kramp (1808) helped popularize the n! notation; the link n! = Γ(n+1) for n ∈ ℕ₀ connects combinatorics to the gamma function (NIST DLMF §5.2). In classical probability each of the n! permutations of n distinct outcomes is often treated as equally likely — hence n! in denominators of classical models (for example, lining up n people).

Conceptually separate: (1) a permutation as a bijection / linear line-up — this page; (2) permutations with repetition n!/(n₁!…nᵣ!) when copies are indistinguishable; (3) k-permutations P(n,k); (4) combinations C(n,k). This calculator answers only (1) with n = ⌊input⌋ ≥ 0. The neighbouring factorial page shares the same product but treats negative inputs differently.

In classical cryptography the number of substitutions of an n-letter alphabet is n! — the order of the key space for a simple substitution cipher. In computer science n! appears in the cost of generating all orders and in sorting lower bounds (worst-case comparisons ≥ log₂(n!)).

Formal properties

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

Identities: P(n) = V(n,n) = n!/(n−n)!; C(n,k)·k! = P(n,k); in particular C(n,n)·n! = n! = P(n). Stirling’s approximation n! ∼ √(2πn)·(n/e)ⁿ estimates magnitude for large n (Concrete Mathematics; Feller). The group Sₙ has order n! and is generated by adjacent transpositions.

In this calculator the practical domain also allows non-integer inputs (floor) and replaces negative n with 0. That is a convention of this calculator, not a theorem about the Γ function: factorial is undefined for negative integers in ℕ, and Γ has poles at non-positive integers.

Full derivation

Step 1 (multiplication rule). Place n distinguishable objects in n seats. Seat 1: n choices. Seat 2: n−1 remaining. … Seat n: 1 choice. Total n·(n−1)·…·1.

Step 2 (factorial definition). Define n! := n·(n−1)·…·1 for n ≥ 1 and 0! := 1. Hence P(n) = n!.

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

Step 4 (link to P(n,k)). The number of injections from a k-set into an n-set is P(n,k) = n!/(n−k)!. When k = n an injection is a bijection, the denominator (n−n)! = 0! = 1, so P(n,n) = n!.

Step 5 (numeric check). For n = 5: 5·4·3·2·1 = 120. For n = 4: 24. For n = 0: 1. These match the browser loop r*=i.

Special cases

P(0) = 1 and P(1) = 1 — same number, different reading (empty arrangement vs one person). P(2) = 2: objects A,B give AB and BA. P(3) = 6. P(6) = 720. P(7) = 5040. P(10) = 3,628,800.

Input 5.7 → ⌊5.7⌋ = 5 → 120. Input −1 → 0 on this page. Permutations with repetition (for example letters in a word with repeats) require dividing by multiplicity factorials — this calculator does not. A uniform random permutation on Sₙ assigns probability 1/n! to each line-up.

When n is very large, the floating-point result first loses integer bit exactness (beyond 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 defect in the definition of n!.

Numerical notes

Computation: n = ⌊a⌋; P(n) = 1·2·…·n for n ≥ 0, otherwise 0. For n = 0 and n = 1 the loop does not multiply and r stays 1. Successive 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 — an educational floating-point arithmetic result.

Neighbour comparison: the factorial page often returns 1 for negatives (via max(0,⌊x⌋)); here a negative returns 0 so the calculator does not pretend a “negative arrangement count” equals 0!.

Related notions and sources

Related on this site: factorial calculator (same product), variations V(n,k), combinations C(n,k). Related in theory: the group Sₙ, permutation sign, cycle type, Stirling numbers of the first kind (cycles), Stirling’s approximation for n!.

Sources: Brualdi — Introductory Combinatorics; Stanley — Enumerative Combinatorics vol. 1; Graham, Knuth, Patashnik — Concrete Mathematics; Feller — An Introduction to Probability Theory and Its Applications (n! in classical models); NIST DLMF §5.2 (factorial / gamma); MathWorld — Permutation; Wikipedia — Permutation / Factorial. Educational tool.

How to use

  1. Enter n in the n field, for example 5.
  2. Click Calculate or wait for the live result. P(5) = 120.
  3. Check the panel: floored n, product, P(n−1), and the P(n,n) identity. The bar diagram shows P(0)…P(n) for moderate n.
  4. P(4) = 24. P(0) = 1. A negative n returns 0 in this calculator.
  5. Choosing k of n with no order lives on combinations. Lining up only k of n lives on variations. Here you arrange everyone.

Symbol glossary

P(n) = n! is the number of linear arrangements of n distinct items. P(5) = 120. P(4) = 24. P(0) = 1.

P(n)
Permutation count for n items; equals n! and P(n,n). Primary result.
n
Item count after floor. Field permutacje-silnia-a. 5.7 → 5.
n!
Factorial: 1·2·…·n; 0! = 1. Same product as on the factorial page for n ≥ 0.
P(n,k)
k-permutations / variations: n!/(n−k)!. Here k = n.

Examples

Example 1

  • n = 5

120

What is P(5)? 120.

Example 2

  • n = 4

24

How many ways to line up 4 people? 24.

Example 3

  • n = 0

1

What is P(0)? 1.

Example 4

  • n = 6

720

What is P(6)? 720.

Example 5

  • n = 10

3,628,800

What is P(10)? 3,628,800.

Example 6

  • n = −3

0

What is P(−3) on this page? 0.

Related calculators

Common questions

What does this calculator compute?

It computes P(n) = n! — the number of linear arrangements of n distinct items. That is the full permutation of an n-element set, the same as P(n,n) = n!/(n−n)!. It does not choose a subset (combinations) or only k seats from n when k < n (variations / k-permutations).

What is P(5)?

The result is 120, because 5! = 1·2·3·4·5 = 120. Five different books on a shelf have 120 orders. That is the first example on this page.

How does P(n) differ from V(n,k) and C(n,k)?

A variation V(n,k) = n!/(n−k)! lines up only k of n items. A combination C(n,k) = n!/(k!(n−k)!) chooses a subset with no order. A permutation lines everyone up: P(n) = V(n,n) = n!.

Why is P(0) = 1?

By the convention 0! = 1 (empty product). The empty list has one way to “arrange” it: arrange nothing. That keeps identities such as C(n,0) = 1 and P(n,n) = n!/0! consistent.

What happens with a negative n?

The calculator returns 0. It takes n = ⌊input⌋ and does not run the factorial product when n < 0. On the factorial page a negative input is replaced by 0 (result 0! = 1) — a different convention and a different result.

Does 5.7 give a different value than 5?

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

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

Each next n multiplies the result by n: P(6) = 720, P(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. The panel warns for large n.

Is this the same as the factorial calculator?

For n ≥ 0 the numeric result matches (n!). The meaning here is combinatorial: you ask for the number of arrangements. For negative n this page returns 0, while the factorial page may fall through to 0! = 1.

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.

Does a comma in 5.0 work?

Yes. 5 and 5.0 both give P(5) = 120. Comma and period are equivalent.

How do I calculate the number of permutations of n items?

Use P(n) = n! = 1·2·…·n (and P(0) = 1). With n = 5: 5·4·3·2·1 = 120. That is the full arrangement of every item, the same as P(n,n).

What is P(7)?

5040, because 7! = 7·720 = 5040. Enter n = 7; the result is the number of linear arrangements of seven distinct items.

Does the calculator compute permutations with repetition or P(n,k)?

No. Here only P(n) = n! for n distinct items. The multinomial n!/(n₁!…nᵣ!) and variations P(n,k) = n!/(n−k)! with k < n live on other cards — they are not here.

Does the result include a list of all arrangements?

No. The result is only the integer P(n). The calculator does not generate the list of permutations and does not classify cycles or the sign of a permutation.

How many ways can 8 people line up?

P(8) = 8! = 40,320. Enter n = 8. That is the classic full-permutation question with no repeats.

The result is P(n) = n!: for n = 5 it is 120; for n = 0 it is 1. A negative n returns 0. Variations and combinations are on neighbouring pages.

Knowledge sources

The definition P(n) = n! and the link to P(n,n) come from established combinatorics texts.

Page Updated November 2, 2026.