Is there a way to calculate permutations and combinations? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is there a way to calculate permutations and combinations?

Help me with a code that can calculate permutations and combinations of a given problem

27th Nov 2018, 1:00 PM
Kavish Bamboli
Kavish Bamboli - avatar
2 Answers
+ 9
U can make your methods for calculating permutaion & combination ● make a method for calculating factorial ● for nCr , calculate n!/[(n-r)!.(r)!] ● for nPr , calculate n!/(n-r)! //U can also calculate nPr first & then use it to calculate nCr fast way to calculate combination : ● make use of formula nCr = (n/r). (n-1)C(r-1) & recursion
27th Nov 2018, 1:58 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
0
Thank you mam
28th Nov 2018, 1:55 PM
Kavish Bamboli
Kavish Bamboli - avatar