Files
freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-95-amicable-chains.english.md
Oliver Eyton-Williams bd68b70f3d Feat: hide blocks not challenges (#39504)
* fix: remove isHidden flag from frontmatter

* fix: add isUpcomingChange

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

* feat: hide blocks not challenges

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2020-09-03 15:07:40 -07:00

1.6 KiB

id, challengeType, title, forumTopicId
id challengeType title forumTopicId
5900f3cc1000cf542c50fede 5 Problem 95: Amicable chains 302212

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:

12496 → 14288 → 15472 → 14536 → 14264 (→ 12496 → ...)

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.

Instructions

Tests

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);

Challenge Seed

function amicableChains() {
  // Good luck!
  return true;
}

amicableChains();

Solution

// solution required