Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
This commit is contained in:
committed by
GitHub
parent
a07f84c8ec
commit
0bd52f8bd1
@ -1,52 +1,55 @@
|
||||
---
|
||||
id: 5900f3811000cf542c50fe94
|
||||
challengeType: 5
|
||||
title: 'Problem 21: Amicable numbers'
|
||||
challengeType: 5
|
||||
forumTopicId: 301851
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
# --description--
|
||||
|
||||
Let d(<var>n</var>) be defined as the sum of proper divisors of <var>n</var> (numbers less than <var>n</var> which divide evenly into <var>n</var>).
|
||||
Let d(`n`) be defined as the sum of proper divisors of `n` (numbers less than `n` which divide evenly into `n`).
|
||||
|
||||
If d(<var>a</var>) = <var>b</var> and d(<var>b</var>) = <var>a</var>, where <var>a</var> ≠ <var>b</var>, then <var>a</var> and <var>b</var> are an amicable pair and each of <var>a</var> and <var>b</var> are called amicable numbers.
|
||||
If d(`a`) = `b` and d(`b`) = `a`, where `a` ≠ `b`, then `a` and `b` are an amicable pair and each of `a` and `b` are called amicable numbers.
|
||||
|
||||
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
|
||||
|
||||
Evaluate the sum of all the amicable numbers under `n`.
|
||||
|
||||
</section>
|
||||
# --hints--
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>sumAmicableNum(1000)</code> should return a number.
|
||||
testString: assert(typeof sumAmicableNum(1000) === 'number');
|
||||
- text: <code>sumAmicableNum(1000)</code> should return 504.
|
||||
testString: assert.strictEqual(sumAmicableNum(1000), 504);
|
||||
- text: <code>sumAmicableNum(2000)</code> should return 2898.
|
||||
testString: assert.strictEqual(sumAmicableNum(2000), 2898);
|
||||
- text: <code>sumAmicableNum(5000)</code> should return 8442.
|
||||
testString: assert.strictEqual(sumAmicableNum(5000), 8442);
|
||||
- text: <code>sumAmicableNum(10000)</code> should return 31626.
|
||||
testString: assert.strictEqual(sumAmicableNum(10000), 31626);
|
||||
`sumAmicableNum(1000)` should return a number.
|
||||
|
||||
```js
|
||||
assert(typeof sumAmicableNum(1000) === 'number');
|
||||
```
|
||||
|
||||
</section>
|
||||
`sumAmicableNum(1000)` should return 504.
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
```js
|
||||
assert.strictEqual(sumAmicableNum(1000), 504);
|
||||
```
|
||||
|
||||
<div id='js-seed'>
|
||||
`sumAmicableNum(2000)` should return 2898.
|
||||
|
||||
```js
|
||||
assert.strictEqual(sumAmicableNum(2000), 2898);
|
||||
```
|
||||
|
||||
`sumAmicableNum(5000)` should return 8442.
|
||||
|
||||
```js
|
||||
assert.strictEqual(sumAmicableNum(5000), 8442);
|
||||
```
|
||||
|
||||
`sumAmicableNum(10000)` should return 31626.
|
||||
|
||||
```js
|
||||
assert.strictEqual(sumAmicableNum(10000), 31626);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
function sumAmicableNum(n) {
|
||||
@ -57,15 +60,7 @@ function sumAmicableNum(n) {
|
||||
sumAmicableNum(10000);
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
const sumAmicableNum = (n) => {
|
||||
@ -86,5 +81,3 @@ const sumAmicableNum = (n) => {
|
||||
return amicableSum/2;
|
||||
};
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user