Permutation
It is an ordered-arrangement/combination of a set of things or collection of objects.
For example, we have a set of letters A, B, and C.....describing permutations as n distinct objects taken r at a time.
Permutation of a list of n elements:
n!= n (n-1)(n-2)(n-3)....3.2.1
nPr = n!/ (n-r)! =n(n-1) (n-2)(n-3).....(n-r+1)
Algorithm
- STEP 1: START
- STEP 2: DEFINE n, r, per, fact1, fact2
- STEP 3: PRINT n, r
- STEP 4: fact1 =n
- STEP 5: REPEAT STEP 6 UNTIL i>=1
- STEP 6: fact1 = fact1*i
- STEP 7: DEFINE number
- STEP 8: SET number = n - r
- STEP 9: fact 2 = fact2*i
- STEP 10: SET per = fact1/fact2
- STEP 11: PRINT per
- STEP 12: END
Java Program
Output:
C program
Output:
C# Program
Output:
Python Program
Output: