feat(curriculum): add two tests to challenge (#41793)
* feat: add two tests * fix: missing backticks * fix: improve wording in tests description * fix: remove not needed link * fix: unify test with description
This commit is contained in:
@ -8,7 +8,7 @@ dashedName: abundant-deficient-and-perfect-number-classifications
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
These define three classifications of positive integers based on their [proper divisors](<https://rosettacode.org/wiki/Proper divisors> "Proper divisors").
|
These define three classifications of positive integers based on their proper divisors.
|
||||||
|
|
||||||
Let $P(n)$ be the sum of the proper divisors of `n` where proper divisors are all positive integers `n` other than `n` itself.
|
Let $P(n)$ be the sum of the proper divisors of `n` where proper divisors are all positive integers `n` other than `n` itself.
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ If `P(n) > n` then `n` is classed as `abundant`
|
|||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Implement a function that calculates how many of the integers from `1` to `20,000` (inclusive) are in each of the three classes. Output the result as an array in the following format `[deficient, perfect, abundant]`.
|
Implement a function that calculates how many of the integers from `1` to `num` (inclusive) are in each of the three classes. Output the result as an array in the following format `[deficient, perfect, abundant]`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
@ -32,32 +32,38 @@ Implement a function that calculates how many of the integers from `1` to `20,00
|
|||||||
assert(typeof getDPA === 'function');
|
assert(typeof getDPA === 'function');
|
||||||
```
|
```
|
||||||
|
|
||||||
`getDPA` should return an array.
|
`getDPA(5000)` should return an array.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(Array.isArray(getDPA(100)));
|
assert(Array.isArray(getDPA(5000)));
|
||||||
```
|
```
|
||||||
|
|
||||||
`getDPA` return value should have a length of 3.
|
`getDPA(5000)` return array should have a length of `3`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(getDPA(100).length === 3);
|
assert(getDPA(5000).length === 3);
|
||||||
```
|
```
|
||||||
|
|
||||||
`getDPA(20000)` should equal [15043, 4, 4953]
|
`getDPA(5000)` should return `[3758, 3, 1239]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(getDPA(20000), solution);
|
assert.deepEqual(getDPA(5000), [3758, 3, 1239]);
|
||||||
|
```
|
||||||
|
|
||||||
|
`getDPA(10000)` should return `[7508, 4, 2488]`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
assert.deepEqual(getDPA(10000), [7508, 4, 2488]);
|
||||||
|
```
|
||||||
|
|
||||||
|
`getDPA(20000)` should return `[15043, 4, 4953]`.
|
||||||
|
|
||||||
|
```js
|
||||||
|
assert.deepEqual(getDPA(20000), [15043, 4, 4953]);
|
||||||
```
|
```
|
||||||
|
|
||||||
# --seed--
|
# --seed--
|
||||||
|
|
||||||
## --after-user-code--
|
|
||||||
|
|
||||||
```js
|
|
||||||
const solution = [15043, 4, 4953];
|
|
||||||
```
|
|
||||||
|
|
||||||
## --seed-contents--
|
## --seed-contents--
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
Reference in New Issue
Block a user