What is Permutation Coefficient
Permutation refers to the process of arranging all the members of a given set to form a sequence. The number of permutations on a set of n elements is given by n! , where “!” represents factorial. The Permutation Coefficient represented by P(n, k) is used to represent the number of ways to obtain an ordered subset having k elements from a set of n elements.
P(10, 2) = 90 P(10, 3) = 720 P(10, 0) = 1 P(10, 1) = 10
To Calculate the Permutation Coefficient, you can use the following recursive approach:
P(n, k) = P(n-1, k) + k * P(n-1, k-1)
Though, this approach can be slow at times. So Dynamic approach is preferred mostly.
INPUT - 100 2 OUTPUT - 9900 INPUT - 69 5 OUTPUT - 1348621560 INPUT - 20 19 OUTPUT - 2432902008176640000 INPUT - 15 11 OUTPUT - 54486432000
Constraints in input
N will always be greater than or equal to K.