C program to calculate the value of nPr Last Updated : 02 Nov, 2021 Comments Improve Suggest changes Like Article Like Report nPr represents n permutation r and value of nPr is (n!) / (n-r)!. C #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; } Enter n: 5 Enter r: 2 5P2 is 20 Time Complexity: O(n) Auxiliary Space: O(n) Please refer Permutation Coefficient for efficient methods to compute nPr. Comment More infoAdvertise with us Next Article C program to calculate the value of nPr K kartik Follow Improve Article Tags : Mathematical Combinatorial DSA factorial Practice Tags : CombinatorialfactorialMathematical Similar Reads Program to find the Depreciation of Value The value of any article or item subject to wear and tear, decreases with time. This decrease is called its Depreciation. Given three variable V1, R and T where V1 is the initial value, R is the rate of depreciation and T is the time in years. The task is to find the value of the item after T years. 3 min read Program to find the count of coins of each type from the given ratio Given the total number of Rupees in a bag and the ratio of coins. The bag contains only 1 Rs, 50 paise, 25 paise coins in X, Y, Z, ratio. The task is to determine the number of 1 Rs coins, 50 Paise coins, and 25 paise coins So that after summation of all these we again get the total rupees given.Exa 6 min read Reliability Design Problem in Dynamic Programming The reliability design problem is the designing of a system composed of several devices connected in series or parallel. Reliability means the probability to get the success of the device. Let's say, we have to set up a system consisting of D1, D2, D3, ............, and Dn devices, each device has s 6 min read Compound Interest - Aptitude Questions and Answers Compound Interest is interest calculated on the initial principal and the accumulated interest from previous periods. It grows exponentially over time because you earn "interest on interest."Formula:A =P(1+ \frac{R}{n})^{nT}Where:A = Final amount (Principal + Interest)P = Principal amount (initial i 6 min read Class 9 RD Sharma Solutions - Chapter 19 Surface Area And Volume of a Right Circular Cylinder - Exercise 19.2 | Set 1 This geometric figure is known as Right Circular Cylinder, which has ample usages in day to day real life situation arises in Engineering, Architecture and Manufacture. It is well used in areas of estimations concerning materials as well as design works concerning the physical structure of an object 13 min read Like