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

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:

主站蜘蛛池模板: 包头市| 腾冲县| 城市| 永城市| 弋阳县| 兴和县| 台南县| 沾益县| 招远市| 迁安市| 仁布县| 南郑县| 来安县| 毕节市| 黄冈市| 冀州市| 蓬溪县| 南昌市| 五华县| 同心县| 滦平县| 四子王旗| 竹山县| 蒲城县| 土默特左旗| 丹江口市| 德庆县| 宜昌市| 龙口市| 桐庐县| 宿州市| 时尚| 永靖县| 福海县| 渭源县| 丰都县| 安徽省| 阿荣旗| 离岛区| 德昌县| 黄山市|