* fix: improve Project Euler descriptions and test case Improve formatting of Project Euler test descriptions. Also add poker hands array and new test case for problem 54 * feat: add typeof tests and gave functions proper names for first 100 challenges * fix: continue fixing test descriptions and adding "before test" sections * fix: address review comments * fix: adjust grids in 18 and 67 and fix some text that reference files rather than the given arrays * fix: implement bug fixes and improvements from review * fix: remove console.log statements from seed and solution
74 lines
1.6 KiB
Markdown
74 lines
1.6 KiB
Markdown
---
|
|
id: 5900f3cc1000cf542c50fede
|
|
challengeType: 5
|
|
title: 'Problem 95: Amicable chains'
|
|
forumTopicId: 302212
|
|
---
|
|
|
|
## Description
|
|
<section id='description'>
|
|
|
|
The proper divisors of a number are all the divisors excluding the number itself. For example, the proper divisors of 28 are 1, 2, 4, 7, and 14. As the sum of these divisors is equal to 28, we call it a perfect number.
|
|
|
|
Interestingly the sum of the proper divisors of 220 is 284 and the sum of the proper divisors of 284 is 220, forming a chain of two numbers. For this reason, 220 and 284 are called an amicable pair.
|
|
|
|
Perhaps less well known are longer chains. For example, starting with 12496, we form a chain of five numbers:
|
|
|
|
<div style="text-align: center;">
|
|
12496 → 14288 → 15472 → 14536 → 14264 (→ 12496 → ...)
|
|
</div>
|
|
|
|
Since this chain returns to its starting point, it is called an amicable chain.
|
|
|
|
Find the smallest member of the longest amicable chain with no element exceeding one million.
|
|
|
|
</section>
|
|
|
|
## Instructions
|
|
<section id='instructions'>
|
|
|
|
</section>
|
|
|
|
## Tests
|
|
<section id='tests'>
|
|
|
|
```yml
|
|
tests:
|
|
- text: <code>amicableChains()</code> should return a number.
|
|
testString: assert(typeof amicableChains() === 'number');
|
|
- text: <code>amicableChains()</code> should return 14316.
|
|
testString: assert.strictEqual(amicableChains(), 14316);
|
|
|
|
```
|
|
|
|
</section>
|
|
|
|
## Challenge Seed
|
|
<section id='challengeSeed'>
|
|
|
|
<div id='js-seed'>
|
|
|
|
```js
|
|
function amicableChains() {
|
|
// Good luck!
|
|
return true;
|
|
}
|
|
|
|
amicableChains();
|
|
```
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</section>
|
|
|
|
## Solution
|
|
<section id='solution'>
|
|
|
|
```js
|
|
// solution required
|
|
```
|
|
|
|
</section>
|