freeCodeCamp/curriculum/challenges/spanish/08-coding-interview-prep/rosetta-code/harshad-or-niven-series.spa...

69 lines
2.0 KiB
Markdown
Raw Normal View History

2018-10-08 17:34:43 +00:00
---
title: Harshad or Niven series
id: 595668ca4cfe1af2fb9818d4
challengeType: 5
2018-10-10 20:20:40 +00:00
videoUrl: ''
localeTitle: Serie Harshad o Niven
2018-10-08 17:34:43 +00:00
---
## Description
2018-10-10 20:20:40 +00:00
<section id="description"><p> Los números de <a href="http://mathworld.wolfram.com/HarshadNumber.html" title="enlace: http://mathworld.wolfram.com/HarshadNumber.html">Harshad</a> o Niven son enteros positivos ≥ 1 que son divisibles por la suma de sus dígitos. </p><p> Por ejemplo, 42 es un <a href="http://rosettacode.org/wiki/oeis:A005349" title="oeis: a005349">número de Harshad</a> ya que 42 es divisible por (4 + 2) sin resto. </p> Supongamos que la serie se define como los números en orden creciente. Tarea: <p> Implementar una función para generar miembros sucesivos de la secuencia de Harshad. </p><p> Úselo para enumerar los primeros veinte miembros de la secuencia y enumerar el primer número de Harshad mayor que 1000. </p></section>
2018-10-08 17:34:43 +00:00
## Instructions
2018-10-10 20:20:40 +00:00
<section id="instructions">
2018-10-08 17:34:43 +00:00
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>isHarshadOrNiven</code> es una función.
testString: 'assert(typeof isHarshadOrNiven === "function", "<code>isHarshadOrNiven</code> is a function.");'
2018-10-10 20:20:40 +00:00
- text: '<code>isHarshadOrNiven()</code> debe devolver <code>{&quot;firstTwenty&quot;: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42],&quot;firstOver1000&quot;: 1002}</code>'
2018-10-08 17:34:43 +00:00
testString: 'assert.deepEqual(isHarshadOrNiven(), res, "<code>isHarshadOrNiven()</code> should return <code>{"firstTwenty": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42],"firstOver1000": 1002}</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function isHarshadOrNiven () {
const res = {
firstTwenty: [],
firstOver1000: undefined
};
// Change after this line
return res;
}
2018-10-10 20:20:40 +00:00
2018-10-08 17:34:43 +00:00
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
2018-10-10 20:20:40 +00:00
// solution required
2018-10-08 17:34:43 +00:00
```
</section>