freeCodeCamp/curriculum/challenges/chinese/08-coding-interview-prep/rosetta-code/evaluate-binomial-coefficie...

63 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Evaluate binomial coefficients
id: 598de241872ef8353c58a7a2
challengeType: 5
videoUrl: ''
localeTitle: 评估二项式系数
---
## Description
<section id="description"><p>写一个函数来计算给定n和k值的二项式系数。 </p><p>推荐这个公式: </p> $ \ binom {n} {k} = \ frac {n} {nkk} = \ frac {nn-1n-2\ ldotsn-k + 1} { kk-1k-2\ ldots 1} $ </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>binom</code>是一个功能。
testString: 'assert(typeof binom === "function", "<code>binom</code> is a function.");'
- text: '<code>binom(5,3)</code>应该返回10。'
testString: 'assert.equal(binom(5, 3), 10, "<code>binom(5,3)</code> should return 10.");'
- text: '<code>binom(7,2)</code>应该返回21。'
testString: 'assert.equal(binom(7, 2), 21, "<code>binom(7,2)</code> should return 21.");'
- text: '<code>binom(10,4)</code>应该返回210。'
testString: 'assert.equal(binom(10, 4), 210, "<code>binom(10,4)</code> should return 210.");'
- text: '<code>binom(6,1)</code>应该返回6。'
testString: 'assert.equal(binom(6, 1), 6, "<code>binom(6,1)</code> should return 6.");'
- text: '<code>binom(12,8)</code>应该返回495。'
testString: 'assert.equal(binom(12, 8), 495, "<code>binom(12,8)</code> should return 495.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function binom (n, k) {
// Good luck!
}
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>