8051 code to find Permutation and Combination

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:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisment ad adsense adlogger