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 List

Returns the number of derangements of 0 through \e n objects.
Controller: CodeCogs

Interface

C++

Derangements List

 
std::vector<int>derangements_listintn )
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.

Example:

#include <codecogs/maths/combinatorics/sequences/derangements_list.h>
#include <iostream>
int main() {
  std::vector<int> result = Maths::Combinatorics::Sequences::derangements_list(10);
  std::cout << "For 0 through 10 objects, the number of derangements are:";
  std::cout << std::endl;
  for (int i = 0; i < result.size(); i++)
    std::cout << result[i] << "  ";
  std::cout << std::endl;
  return 0;
}

Output:

For 0 through 10 objects, the number of derangements are:
1  0  1  2  9  44  265  1854  14833  133496  1334961

References:

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

Returns

the number of derangements of 0 through 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.