Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/rosetta-code/evaluate-binomial-coefficients.md
Oliver Eyton-Williams dec409a4bd fix: s/localeTitle/title/g
2020-10-06 23:10:08 +05:30

1.3 KiB
Raw Blame History

id, challengeType, videoUrl, title
id challengeType videoUrl title
598de241872ef8353c58a7a2 5 评估二项式系数

Description

写一个函数来计算给定n和k值的二项式系数。

推荐这个公式:

$ \ binom {n} {k} = \ frac {n} {nkk} = \ frac {nn-1n-2\ ldotsn-k + 1} { kk-1k-2\ ldots 1} $

Instructions

Tests

tests:
  - text: <code>binom</code>是一个功能。
    testString: assert(typeof binom === 'function');
  - text: '<code>binom(5,3)</code>应该返回10。'
    testString: assert.equal(binom(5, 3), 10);
  - text: '<code>binom(7,2)</code>应该返回21。'
    testString: assert.equal(binom(7, 2), 21);
  - text: '<code>binom(10,4)</code>应该返回210。'
    testString: assert.equal(binom(10, 4), 210);
  - text: '<code>binom(6,1)</code>应该返回6。'
    testString: assert.equal(binom(6, 1), 6);
  - text: '<code>binom(12,8)</code>应该返回495。'
    testString: assert.equal(binom(12, 8), 495);

Challenge Seed

function binom (n, k) {
  // Good luck!
}

Solution

// solution required

/section>