package com.thealgorithms.maths; import java.util.LinkedHashSet; import java.util.Set; import org.apache.commons.lang3.tuple.Pair; /** * Amicable numbers are two different natural numbers that the sum of the * proper divisors of each is equal to the other number. * (A proper divisor of a number is a positive factor of that number other than the number itself. * For example, the proper divisors of 6 are 1, 2, and 3.) * A pair of amicable numbers constitutes an aliquot sequence of period 2. * It is unknown if there are infinitely many pairs of amicable numbers. * *
* link: https://en.wikipedia.org/wiki/Amicable_numbers *
* Simple Example: (220, 284)
* 220 is divisible by {1,2,4,5,10,11,20,22,44,55,110} <-SUM = 284
* 284 is divisible by {1,2,4,71,142} <-SUM = 220.
*/
public final class AmicableNumber {
private AmicableNumber() {
}
/**
* Finds all the amicable numbers in a given range.
*
* @param from range start value
* @param to range end value (inclusive)
* @return list with amicable numbers found in given range.
*/
public static Set