nPr represents n permutation r and value of nPr is (n!) / (n-r)!.

`#include<stdio.h> ` ` ` `int` `fact(` `int` `n) ` `{ ` ` ` `if` `(n <= 1) ` ` ` `return` `1; ` ` ` `return` `n*fact(n-1); ` `} ` ` ` `int` `nPr(` `int` `n, ` `int` `r) ` `{ ` ` ` `return` `fact(n)/fact(n-r); ` `} ` ` ` `int` `main() ` `{ ` ` ` `int` `n, r; ` ` ` `printf` `(` `"Enter n: "` `); ` ` ` `scanf` `(` `"%d"` `, &n); ` ` ` ` ` `printf` `(` `"Enter r: "` `); ` ` ` `scanf` `(` `"%d"` `, &r); ` ` ` ` ` `printf` `(` `"%dP%d is %d"` `, n, r, nPr(n, r)); ` ` ` ` ` `return` `0; ` `}` |

*chevron_right*

*filter_none*

Enter n: 5 Enter r: 2 5P2 is 20

Please refer Permutation Coefficient for efficient methods to compute nPr.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Program to calculate the value of nPr
- Find a pair (n,r) in an integer array such that value of nPr is maximum
- Program to calculate the value of sin(x) and cos(x) using Expansion
- Program to calculate value of nCr
- Program to calculate the value of nCr Efficiently
- Calculate the Discriminant Value
- Find minimum number of Log value needed to calculate Log upto N
- Write a program to calculate pow(x,n)
- Efficient program to calculate e^x
- Program to calculate the number of odd days in given number of years
- Program to calculate distance between two points
- Program to calculate area and volume of a Tetrahedron
- Program to calculate Area Of Octagon
- Program to calculate GST from original and net prices
- Program to calculate Percentile of a student based on rank
- Program to calculate the Surface Area of a Triangular Prism
- Program to calculate area of an Circle inscribed in a Square
- Program to calculate distance between two points in 3 D
- Program to calculate Profit Or Loss
- Program to calculate the profit sharing ratio