8051

8051 code to find Permutation and Combination

This program finds the value of permutation and combination for given two input numbers

 Algorithm

1) Store the value of n to R0,store the value of r to R1 and store the value (n-r) to R2.
2) Compare if n>r continue the process, if n<r then stop computation, if n=r then assign permutation as n! and combination as 1.
3) Calculate the n!,r!,(n-r)! and store in R3,R4,R5 respectively.
4) Calculate permutation by dividing n!/(n-r)!
5) Calculate combination by dividing n!/(n-r)!*r!

Code goes here: