C Programming Code Examples C > Mathematics Code Examples C program to Calculate the Value of nPr C program to Calculate the Value of nPr This C Program calculates the value of nPr. Here we need find all possible rearrangement of the element i.e all the possible permutation value. A permutation is a re-arrangement of elements of a set. Any duplications of the collected elements in different orders is allowed. A permutation therefore tends to be a large number. #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 j) { if (j <= 1) return 1; return j * fact(j - 1); }