**Program to find NcR NpR**

**nCr = n! / r!(n-r)!**

**nPr = n! / (n-r)!**

Therefore, NPR= NCR*r!

Where C stands for **Combinations**, and P stands for **permutation**.

**Algorithm**

- Get Input n,r from the user.
- Function named
*factorial*is created which calculates n! Or (n-r)! Depending upon what value is to be calculated.*nCr = n! / r!(n-r)!*

*nPr = nCr *r!* - Print ncr and npr.

**Code**

```
#include <iostream>
long int factorial(int y)
{
int i, fact = 1;
for (i = 2; i <= y; i++)
{
fact = fact * i;
}
return fact;
}
int main()
{
int n, r;
long int ncr, npr;
std::cout << "Enter the value of n : ";
std::cin >> n;
std::cout << "Enter the value of r : ";
std::cin >> r;
npr = factorial(n) / factorial(n - r);
ncr = npr / factorial(r);
std::cout << "NCR value = " << ncr;
std::cout << "\nNPR value = " << npr;
return 0;
}
```

Report Error/ Suggestion