You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
390 B
C
21 lines
390 B
C
/*
|
|
* C program to Calculate the Value of nPr
|
|
*/
|
|
#include <stdio.h>
|
|
|
|
void main(void)
|
|
{
|
|
printf("%d\n", fact(8));
|
|
int n, r;
|
|
printf("Enter value for n and r\n");
|
|
scanf("%d%d", &n, &r);
|
|
int npr = fact(n) / fact(n - r);
|
|
printf("\n Permutation values is = %d", npr);
|
|
}
|
|
|
|
int fact(int x)
|
|
{
|
|
if (x <= 1)
|
|
return 1;
|
|
return x * fact(x - 1);
|
|
} |