|
THESE ARE THE INSTRUCTIONS
------------------------------------------------------------------------To check if n belongs to an amicable pair, find the sum (sum1) of the factors of n. Then find the sum (sum2) of all the factors of sum1. If sum2 == n, you have found a pair of amicable numbers.
Do not print any pair of perfect numbers in your output.
Do not print a pair of amicable numbers more than once.
Here are some hints for writing the source code for this project:
Write a static method (below your main method) defined like this:
public static int sumFactors(int n)
{
... // Body of method goes here.
}
It should compute the sum of all the factors of the input n.
Test your sumFactors method for finding perfect numbers before you try to use it for finding amicable numbers.
In your main method, write a double for loop that checks all the numbers n and m between 2 and upperBound. Check that the sum of the factors of n equals m and that the sum of the factors of m equals n.
-------------------------------------------------------------------
|