FUNCTION
fixed_permutation
Calculates the number of permutations of \e n objects with \e m fixed.
You're viewing an older version of this page (#277). View the current version.
Interface
#include <codecogs/maths/combinatorics/sequences/fixed_permutation.h>
using namespace Maths::Combinatorics::Sequences;
A permutation of n objects with m fixed is a permutation in which exactly m of the objects retain their original positions. In more formal terms, consider the following permutation
then has exactly m fixed objects if
If , the permutation is a derangement, while if
, the permutation is the identity.
The number of permutations of n objects with m fixed is given by
or
where is the number of derangements of
objects.
This function calculates the value of based on the above formula.
References
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html
Example 1
#include <codecogs/maths/combinatorics/sequences/fixed_permutation.h>
#include <iostream>
int main()
{
std::cout << "The number of permutations of 10 elements with 5 fixed is: ";
std::cout << Maths::Combinatorics::Sequences::fixed_permutation(10, 5) << std::endl;
return 0;
}Output
The number of permutations of 10 elements with 5 fixed is: 11088Parameters
Returns
Interactive Calculator
Computing…
Set a range above first to export a graph.