Advanced Derangement Calculator

Solve advanced derangement cases with formulas and tables. Visualize recurrence growth, probability, and approximation behavior. Download clean outputs for study, reviews, sharing, and records.

Calculator Input

Use 0 to 170.
Counts arrangements with exactly k fixed points.
Choose 1 to 25 for the chart.
Applies to shown numeric results.

Formula Used

Derangements count permutations where no item remains in its original position.

!n = n! × Σ[(-1)^k / k!] for k = 0 to n

This is the inclusion-exclusion formula.

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

This recurrence is efficient for computation.

P(no fixed points) = !n / n!

This gives the probability that a random permutation has no fixed points.

Count(exactly r fixed points) = C(n, r) × !(n - r)

This counts arrangements with exactly r fixed points.

!n ≈ n! / e

The approximation becomes very accurate as n increases.

How to Use This Calculator

  1. Enter the total number of items in the permutation.
  2. Enter the number of fixed points you want to analyze.
  3. Choose a chart upper limit for comparison values.
  4. Select how many decimals to display in outputs.
  5. Press Calculate Derangements.
  6. Review the exact count, approximation, probabilities, and fixed-point analysis.
  7. Use the CSV button for spreadsheets and the PDF button for reports.

Example Data Table

n n! Exact !n Rounded n!/e Probability !n / n!
1 1 0 0 0
2 2 1 1 0.5
3 6 2 2 0.333333
4 24 9 9 0.375
5 120 44 44 0.366667
6 720 265 265 0.368056

Frequently Asked Questions

1. What is a derangement?

A derangement is a permutation in which no element stays in its original position. It is useful in matching problems, secret exchanges, coding theory, and probability analysis.

2. What does !n mean?

The notation !n represents the number of derangements of n distinct items. It is different from n!, which counts all permutations, including those with fixed positions.

3. Why is n!/e used as an approximation?

The inclusion-exclusion series for derangements converges toward n!/e. For larger n, rounding n!/e usually gives the exact derangement count.

4. What is the probability of a derangement?

The probability is !n divided by n!. As n grows, this probability approaches 1/e, which is about 0.367879.

5. Can this calculator handle exactly r fixed points?

Yes. It uses C(n, r) × !(n-r) to count permutations with exactly r fixed points. This extends the calculator beyond pure derangements.

6. Why can large outputs show rounding differences?

Very large factorial and derangement values exceed normal exact integer ranges. The calculator then displays floating-point approximations, which may introduce small rounding differences.

7. When is the recurrence formula useful?

The recurrence !n = (n-1)(!(n-1)+!(n-2)) is efficient for iterative calculation. It avoids summing every inclusion-exclusion term from scratch.

8. Where are derangements used in practice?

They appear in scheduling, seating, assignment shuffles, encrypted mappings, reliability studies, random testing, and probability models involving forbidden matches.

Related Calculators

probability combination calculatorbinomial coefficient calculatorpermutation with repetition calculatordouble factorial calculatorcombination with repetition calculatoranagram calculatorstirling number calculatorpartition number calculatorsubset sum calculatorsubset calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.