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

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

主站蜘蛛池模板: 故城县| 汉沽区| 东安县| 韶关市| 石门县| 库车县| 长宁区| 册亨县| 凤城市| 江西省| 都江堰市| 武安市| 杭锦后旗| 桃源县| 夏河县| 商丘市| 昭平县| 梧州市| 商洛市| 太白县| 育儿| 准格尔旗| 崇明县| 安吉县| 林口县| 时尚| 右玉县| 桑日县| 青神县| 日照市| 景宁| 体育| 资溪县| 固阳县| 南澳县| 孟村| 十堰市| 乌鲁木齐县| 五峰| 五大连池市| 海淀区|