2018-10-08 13:34:43 -04:00
---
title: Evaluate binomial coefficients
id: 598de241872ef8353c58a7a2
challengeType: 5
2018-10-10 16:20:40 -04:00
videoUrl: ''
localeTitle: Evaluar coeficientes binomiales.
2018-10-08 13:34:43 -04:00
---
## Description
2018-10-10 16:20:40 -04:00
< section id = "description" >< p > Escribe una función para calcular el coeficiente binomial para el valor dado de n y k. </ p >< p > Se recomienda esta fórmula: </ p > $ \ binom {n} {k} = \ frac {n!} {(nk)! k!} = \ frac {n (n-1) (n-2) \ ldots (n-k + 1)} { k (k-1) (k-2) \ ldots 1} $ </ section >
2018-10-08 13:34:43 -04:00
## Instructions
2018-10-10 16:20:40 -04:00
< section id = "instructions" >
2018-10-08 13:34:43 -04:00
< / section >
## Tests
< section id = 'tests' >
```yml
tests:
- text: < code > binom</ code > es una función.
testString: 'assert(typeof binom === "function", "< code > binom< / code > is a function.");'
2018-10-10 16:20:40 -04:00
- text: '< code > binom(5,3)</ code > debe devolver 10.'
2018-10-08 13:34:43 -04:00
testString: 'assert.equal(binom(5, 3), 10, "< code > binom(5,3)< / code > should return 10.");'
2018-10-10 16:20:40 -04:00
- text: '< code > binom(7,2)</ code > debe devolver 21.'
2018-10-08 13:34:43 -04:00
testString: 'assert.equal(binom(7, 2), 21, "< code > binom(7,2)< / code > should return 21.");'
2018-10-10 16:20:40 -04:00
- text: '< code > binom(10,4)</ code > debe devolver 210.'
2018-10-08 13:34:43 -04:00
testString: 'assert.equal(binom(10, 4), 210, "< code > binom(10,4)< / code > should return 210.");'
2018-10-10 16:20:40 -04:00
- text: '< code > binom(6,1)</ code > debe devolver 6.'
2018-10-08 13:34:43 -04:00
testString: 'assert.equal(binom(6, 1), 6, "< code > binom(6,1)< / code > should return 6.");'
2018-10-10 16:20:40 -04:00
- text: '< code > binom(12,8)</ code > debe devolver 495.'
2018-10-08 13:34:43 -04:00
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!
}
2018-10-10 16:20:40 -04:00
2018-10-08 13:34:43 -04:00
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
2018-10-10 16:20:40 -04:00
// solution required
2018-10-08 13:34:43 -04:00
```
< / section >