Showing posts with label n choose k. Show all posts
Showing posts with label n choose k. Show all posts

Friday, June 2, 2017

n choose k

Find the number of ways one can select k items from a collection of n items.
Usage:

echo(choose(17,13));

function choose(n, k)=
     k == 0? 1
    : (n * choose(n - 1, k - 1)) / k;