Menu
Question Index
...

Write a program to find if the given numbers are Amicable. For two numbers to be amicable, the sum of the proper factors of first number is equal to the second number and sum of the proper factors of second number is equal to the first number.

For e.g., the factors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, 110 and there sum is 284. Where as for 284 the factors are 1, 2, 4, 71, 142 and there is 220. So the numbers 220 and 284 are amicable. Note that although the number is factor of itself, we should not consider it while summing up.

Input (int, int) Output (boolean)
220, 284 true
150, 174 false
1184, 1210 true
512, 438 false



class AreNumbersAmicable
{
    public static void main(String s[])
    {
        System.out.println("The given numbers are Amicable : " + findAmicableNumbers(220, 284));

    }


    public static boolean findAmicableNumbers(int firstNumber, int secondNumber) {
    }
    

}

Doubts

Problems

Topic: for Loop In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App