C Program to calculate Permutation and Combination

The following is a C program to compute  Permutation and Combination:

Expected Output:

1st run:

2nd run:

How it works

Nothing magical here we are simply using the formula to calculate permutation and combination.

The permutations of n different objects taken r at a time is given by:

nPr  = \frac{n!}{(n-r)!}

The combinations of n different objects taken r at a time is given by:

nCr  = \frac{n!}{r!(n-r)!}


Recommended Reading:

Leave a Comment

%d bloggers like this: