eg. 14 and 15

Find all the factors of 14 and 15.

1,2,7,14 are factors of 14

1,3,5,15 are factors of 15

Sum all the factors of two numbers and

if sum of factors of two numbers taken are respectively equal they are Amicable numbers.

```
class Amicable
{
public static void main(String[] args)
{
int num1=Integer.parseInt(args[0]);
int num2=Integer.parseInt(args[1]);
int sum1=0,sum2=0;
for(int i=1;i<=num1;i++)
{
if(num1%i==0)
sum1+=i;
}
for(int i=1;i<=num2;i++)
{
if(num2%i==0)
sum2+=i;
}
if(sum1==sum2)
System.out.println(num1+" and "+num2+" are Amicable numbers");
else
System.out.println(num1+" and "+num2+" are not Amicable numbers");
}
}
```

About the Author