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

  • 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:

主站蜘蛛池模板: 安国市| 垦利县| 鹤庆县| 惠安县| 望江县| 永清县| 巴彦淖尔市| 江西省| 五莲县| 三门峡市| 北川| 襄城县| 保康县| 堆龙德庆县| 天全县| 麦盖提县| 内黄县| 镇宁| 龙州县| 大姚县| 平定县| 施甸县| 延津县| 安化县| 乐亭县| 沅陵县| 灌云县| 玉龙| 惠安县| 陈巴尔虎旗| 梁河县| 云安县| 南木林县| 准格尔旗| 娄底市| 石棉县| 雷山县| 亚东县| 黔西| 太保市| 藁城市|