Escreva uma função para calcular o coeficiente binomial para o valor dado de n e k.
Esta fórmula é recomendada:
$ \ binom {n} {k} = \ frac {n!} {(nk)! k!} = \ frac {n (n-1) (n-2) \ ldots (n-k + 1)} { k (k-1) (k-2) \ ldots 1} $binom
é uma função.
testString: 'assert(typeof binom === "function", "binom
is a function.");'
- text: 'binom(5,3)
deve retornar 10.'
testString: 'assert.equal(binom(5, 3), 10, "binom(5,3)
should return 10.");'
- text: 'binom(7,2)
deve retornar 21.'
testString: 'assert.equal(binom(7, 2), 21, "binom(7,2)
should return 21.");'
- text: 'binom(10,4)
deve retornar 210.'
testString: 'assert.equal(binom(10, 4), 210, "binom(10,4)
should return 210.");'
- text: 'binom(6,1)
deve retornar 6.'
testString: 'assert.equal(binom(6, 1), 6, "binom(6,1)
should return 6.");'
- text: 'binom(12,8)
deve retornar 495.'
testString: 'assert.equal(binom(12, 8), 495, "binom(12,8)
should return 495.");'
```