I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.42
sub units 0.00
+
0

Derangements Number

Calculates the number of derangements of \e n objects.
Controller: CodeCogs

Interface

C++
Excel

Derangements Number

 
intderangements_numberintn )
A derangement of n objects is a permutation with no fixed points. If we symbolize the permutation by \inline  \sigma, then for a derangment, \inline  \sigma(i) is never equal to \inline  i.

The number of derangements of n objects is given by the following formula

Based on the inclusion/exclusion law we are allowed to write

where \inline  \lceil x \rceil is the ceiling function.

Example:

#include <codecogs/maths/combinatorics/sequences/derangements_number.h>
#include <iostream>
int main()
{
  for (int i = 0; i < 10; i++)
    std::cout << i << " " << Maths::Combinatorics::Sequences::derangements_number(i) << std::endl;
  return 0;
}

Output:

0 1
1 0
2 1
3 2
4 9
5 44
6 265
7 1854
8 14833
9 133496

References:

SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html

Parameters

nthe number of objects

Returns

the number of derangements of n objects

Authors

Lucian Bentea (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.