Derangement Calculator

Calculate !n (subfactorial) - the number of permutations where no element appears in its original position.

Calculate !n

!5 (Derangements)

44

5! (Permutations)

120

Probability of Derangement

36.6667%

!5 / 5! = 0.36666667

Limit as n → ∞

36.7879%

1/e ≈ 0.36787944

Derangement vs Factorial

n!nn!!n/n!
0111
1010.000000
2120.500000
3260.333333
49240.375000
5441200.366667
62657200.368056
7185450400.367857
814833403200.367882
91334963628800.367879
10133496136288000.367879
1114684570399168000.367879

Formulas

Recurrence

!n = (n-1)(!(n-1) + !(n-2))

Inclusion-Exclusion

!n = n! × Σ(-1)^k/k!

Nearest Integer

!n = round(n!/e)

Limit

lim(!n/n!) = 1/e

The Hat Check Problem

If n people check their hats and the hats are returned randomly, what is the probability that no one gets their own hat back? The answer is !n/n!, which approaches 1/e ≈ 36.79% as n increases. Remarkably, this probability is nearly constant for n ≥ 4.

What Is a Derangement Calculator?

A derangement calculator helps you perform derangement calculations quickly and accurately. Enter your values and get instant results with step-by-step breakdowns showing exactly how each result was derived.

This calculator handles 0 input values: . Results are computed using standard mathematical formulas and displayed with precision suitable for homework, professional work, and quick references.

The Derangement Formula

The calculator applies the following mathematical relationships:

Derangement Formula

Computed from input values using standard formulas

Where:

  • Input= Enter values in the input fields to compute results

Understanding the Results

The results display shows the computed value{s} along with related quantities. Each result is computed using JavaScript's built-in Math functions (Math.PI, Math.sqrt, etc.) for maximum precision.

All results are shown to four decimal places by default, which is sufficient for most practical applications including construction, engineering, and academic work.

How to Use This Calculator

  1. Read the results: The calculator updates immediately as you type, showing computed values with full step-by-step breakdowns.

Real-World Applications

Derangement calculations appear in numerous fields. In education, students use them to verify homework answers and understand the underlying formulas. In engineering, these calculations inform design decisions and safety margins. In everyday life, quick calculations help with home improvement projects, budgeting, and planning.

The specific formulas used by this calculator are standard in the field and can be verified in any mathematics or engineering textbook. Bookmark this page as a quick reference whenever you need to perform derangement calculations.

Worked Examples

Example Calculation

Problem:

Use the default values to compute the result.

Solution Steps:

  1. 2The calculator computes the result using the appropriate formula.
  2. 3Review the step-by-step breakdown to understand the process.

Result:

The computed result is displayed in the highlighted result card above.

Tips & Best Practices

  • Double-check your inputs — a single typo can produce dramatically different results.
  • Use consistent units throughout — don't mix centimeters with inches or meters with feet.
  • Review the step-by-step breakdown to verify that the formula was applied correctly for your inputs.
  • Bookmark this page for quick access to derangement calculations whenever needed.
  • For very large or small numbers, the calculator may display results in exponential notation.
  • Compare results with manual calculations occasionally to build confidence in the tool and your math skills.

Frequently Asked Questions

Calculations use JavaScript's built-in Math functions with double-precision floating-point arithmetic, providing approximately 15 significant digits of accuracy. Displayed values are rounded to four decimal places for readability while maintaining sufficient precision for most applications.
This is a web-based calculator that requires an internet connection to load. Once loaded, all calculations are performed client-side in your browser, so no data is sent to any server.
The calculator is unit-agnostic — enter your values in any consistent unit system (metric or imperial), and results will be in the corresponding units. Mixing unit systems will produce incorrect results.
Yes, this calculator is completely free with no registration required. Use it as many times as you need for homework, professional work, or personal projects.
If you find an issue or have a suggestion for improving this calculator, please reach out through the contact options on the site. We're always looking to make our tools more useful and accurate.

Sources & References

Last updated: 2026-06-06

💡

Help us improve!

How would you rate the Derangement Calculator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Handbook of Mathematical Functions

by Abramowitz & Stegun

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.