You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Amicable numbers are two different natural numbers related in such a way that the sum of the proper divisors of
/// each is equal to the other number. That is, σ(a)=b+a and σ(b)=a+b, where σ(n) is equal to the sum of positive divisors of n (see also divisor function).
/// See <a href="https://en.wikipedia.org/wiki/Amicable_numbers">here</a> for more info.
/// </summary>
public static class AmicableNumbersChecker
{
/// <summary>
/// Checks if two numbers are amicable or not.
/// </summary>
/// <param name="x">First number to check.</param>
/// <param name="y">Second number to check.</param>
/// <returns>True if they are amicable numbers. False if not.</returns>
public static bool AreAmicableNumbers(int x, int y)
{
return SumOfDivisors(x) == y && SumOfDivisors(y) == x;