So many choices - MATLAB Cody - MATLAB Central

Problem 160. So many choices

Difficulty:Rate

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

52.63% Correct | 47.37% Incorrect
Last Solution submitted on Feb 24, 2025

Problem Comments

Solution Comments

Show comments

Group

Paper-&-pencil Games Image
Paper-&-pencil Games
  • 19 Problems
  • 4 Finishers

Problem Recent Solvers456

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page