Tag Archives: binomial coefficient

Calculate a row of Pascal’s triangle in C#

Pascal’s triangle starts with a 1 at the top. To construct a new row for the triangle, you add a 1 below and to the left of the row above. After that, each entry in the new row is the … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | 2 Comments

Generate all selections of K items from a set of N items in C#

This example is somewhat similar to Generate all of the permutations of a set of objects in C#. The basic idea is to use a recursive method to assign the next item to the combination. The first call to the … Continue reading

Posted in algorithms, combinatorics, mathematics | Tagged , , , , , , , , , , , , , , , | 3 Comments

Calculate the binomial coefficient “N choose K” efficiently in C#

The binomial coefficient, written and pronounced “n choose k,” is the number of ways you can pick k items from a set of n items. For example, suppose you have a deck of 5 cards (n = 5) and you … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , , | 9 Comments