二项式系数表的C程序

2023年 8月 29日 39.6k 0

Given with a positive integer value let’s say ‘val’ and the task is to print the value of binomial coefficient B(n, k) where, n and k be any value between 0 to val and hence display the result.

What is Binomial Coefficient

Binomial coefficient (n, k) is the order of choosing ‘k’ results from the given ‘n’ possibilities. The value of binomial coefficient of positive n and k is given by

$$C_k^n=frac{n!}{(n-k)!k!}$$

where, n >= k

Example

的中文翻译为:

示例

Input-: B(9,2)
Output-:

登录后复制

$$B_2^9=frac{9!}{(9-2)!2!}$$

$$frac{9times 8times 7times 6times 5times 4times 3times 2times 1}{6times 5times 4times 3times 2times 1)times 2times 1}=frac{362,880}{1440}=252$$

What is Binomial Coefficient Table

The Binomial Coefficient Table is formed for calculating the multiple values that can be generated between n and k.

Example

的中文翻译为:

示例

Input-: value = 5
Output-:

登录后复制

二项式系数表的C程序

Approach used in the below program is as follows −

  • Input the variable ‘val’ from the user for generating the table
  • Start the loop from 0 to ‘val’ because the value of binomial coefficient will lie between 0 to ‘val’
  • Apply the formula given, if n and k is not 0

    B(m, x) = B(m, x - 1) * (m - x + 1) / x

  • Print the result

START
Step 1-> declare function for binomial coefficient table
int bin_table(int val)
Loop For int i = 0 and i

相关文章

JavaScript2024新功能:Object.groupBy、正则表达式v标志
PHP trim 函数对多字节字符的使用和限制
新函数 json_validate() 、randomizer 类扩展…20 个PHP 8.3 新特性全面解析
使用HTMX为WordPress增效:如何在不使用复杂框架的情况下增强平台功能
为React 19做准备:WordPress 6.6用户指南
如何删除WordPress中的所有评论

发布评论