NPR

This algorithm finds all possible rearrangement of the element i.e all the possible permutation value.



									/*****Please include following header files*****/
// stdint.h
/***********************************************/

int64_t Factorial(int number) {
	if (number < 0)
		return -1; //Error

	int64_t result = 1;

	for (int i = 1; i <= number; ++i)
		result *= i;

	return result;
}

long NPR(int n, int r) {
	return Factorial(n) / Factorial(n - r);
}
								


Example

									int64_t ncr = NPR(5, 2);
								


Output

									20