官术网_书友最值得收藏!

  • The Modern C# Challenge
  • Rod Stephens
  • 136字
  • 2021-08-13 15:23:52

6. Binomial coefficients

The binomial coefficient of N and K gives the number of ways that you can pick N values from a set of K values. The binomial coefficient is usually written as and is pronounced N choose K.

For example, suppose you have a set of four values, {A, B, C, D}. The possible ways to select two of those values are {A, B}, {A, C}, {A, D}, {B, C}, {B, D}, and {C, D}. There are six possible ways to select two items from the original set of four items, so =6.

You can use the following formula to calculate binomial coefficients:

For the example where we select two items out of four, the formula gives the following:

Write a program that calculates binomial coefficients. Test your program by verifying the following values:

主站蜘蛛池模板: 镇雄县| 枝江市| 东兰县| 宁晋县| 林口县| 新疆| 彭水| 宣城市| 师宗县| 拉萨市| 炉霍县| 昭平县| 遵义县| 通海县| 博乐市| 巢湖市| 潜江市| 新田县| 东山县| 浙江省| 忻州市| 日土县| 东阿县| 南汇区| 汨罗市| 呼伦贝尔市| 沾化县| 齐河县| 和政县| 荔波县| 长汀县| 竹北市| 沙雅县| 喀什市| 册亨县| 原阳县| 丹凤县| 紫阳县| 上高县| 饶阳县| 蒙阴县|