Problem 160. So many choices
For inputs n and k (in that order), output the number of ways that k objects can be chosen from amongst n distinct objects. [The order of the selected objects is irrelevant.]
For example, suppose you have 4 blocks: red, green, blue, yellow. How many ways are there to select 2 of them? There are 6 ways: RG, RB, RY, GB, GY, BY. [Remember the ordering is irrelevant, so GR is equivalent to RG, and therefore does not count as a distinct choice.]
So, function(4,2) ---> 6.
Solution Stats
Problem Comments
-
3 Comments
Why in my pc showing correct but not in this
@Sumit, you are probably using a function from a toolbox (e.g. statistics toolbox) that is not available to Cody.
http://onlinestatbook.com/2/probability/permutations.html
Solution Comments
Show commentsProblem Recent Solvers470
Suggested Problems
-
2160 Solvers
-
Project Euler: Problem 1, Multiples of 3 and 5
3653 Solvers
-
Arrange Vector in descending order
13074 Solvers
-
Element by element multiplication of two vectors
393 Solvers
-
Calculate Amount of Cake Frosting
28649 Solvers
More from this Author23
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!