fixed permutation
Calculates the number of permutations of \e n objects with \e m fixed.
Controller: CodeCogs
| intfixed_permutation( | int | n | |
| int | m | ) |
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.htmlExample 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: 11088
Parameters
n the size of the permutation m the number of fixed objects
Returns
- the number of permutations of n items with m fixed
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.



1.40
