+ 3

Help me count the number of combinations

I need to write a program, which can count the number of combinations. I.e. i need to write program which should count (n!/(k!*(n-k)!), where n > k. Can you help me?

2nd Feb 2018, 7:03 PM
Лорд Джокер
Лорд Джокер - avatar
1 Respuesta
+ 3
What I would do is start by creating a function that calculates the factorial of a number. This can be done by creating a recursive function, or a function that repeatedly calls itself until a certain condition is satisfied. From there, you can take 2 variables as user input, put them into the equation with the factorial function, and it should work! If you want, you could also add some conditional statements testing whether or not n is greater than k and do something if it is not.
2nd Feb 2018, 7:54 PM
Faisal
Faisal - avatar