#include <stdio.h>
long factorial(int);
long find_ncr(int x, int y);
long find_npr(int t, int s);
int main()
{
int n, r;
long nCr, nPr;
printf("\n Enter n= ");
scanf("%d",&n);
printf("\n Enter r= ");
scanf("%d",&r);
nCr = find_ncr(n,r);
nPr = find_npr(n,r);
printf("\n 1) Combination of %dC%d = %d\n", n, r, nCr);
printf("\n 2) Permutations of %dP%d = %d\n", n, r, nPr);
return 0;
}
long find_ncr(int x, int y )
{
long result;
result=factorial(x)/factorial(x-y)*factorial(y);
return (result);
}
long factorial(int);
long find_ncr(int x, int y);
long find_npr(int t, int s);
int main()
{
int n, r;
long nCr, nPr;
printf("\n Enter n= ");
scanf("%d",&n);
printf("\n Enter r= ");
scanf("%d",&r);
nCr = find_ncr(n,r);
nPr = find_npr(n,r);
printf("\n 1) Combination of %dC%d = %d\n", n, r, nCr);
printf("\n 2) Permutations of %dP%d = %d\n", n, r, nPr);
return 0;
}
long find_ncr(int x, int y )
{
long result;
result=factorial(x)/factorial(x-y)*factorial(y);
return (result);
}
long find_npr(int t, int s)
{
long result1;
result1=factorial(t)/factorial(t-s);
return (result1);
}
{
long result1;
result1=factorial(t)/factorial(t-s);
return (result1);
}
long factorial(int A)
{
int i;
long r=1;
for( i=1; i<=A; i++ )
r=r*i;
return (r);
}
{
int i;
long r=1;
for( i=1; i<=A; i++ )
r=r*i;
return (r);
}