The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Need some serious help

Posted by chris on February 08, 2002 at 6:46 PM

I have this problem and i don't really know how to start it. Any basic ideas would be appreciated. I don't need the program just an idea of how I can do this. Thankz

Amicable Number Problem. Given any integer n, we can determine �the sum of its divisors.� For example, 30 has divisors 1, 2, 3, 5, 6, 10, and 15, the sum of these divisors is 42. Or consider 35, its divisors are 1, 5, and 7, and their sum is 13.

Now consider the numbers 220 and 284. They have a very interesting property. If you sum of all of the divisors of 220, you get 284. Conversely if you sum all of the divisors of 284 then you get 220. Two numbers x, y are called an �amicable pair� if the sum of the divisors of x is y, and at the same time, the sum of the divisors of y is x.

The program you will write, named, begins by requesting an integer n be input from the user. It then computes and prints out all amicable pairs x, y where at least one of the numbers x or y is smaller than n. The program terminates after it has completed the computation. The program should not duplicate any values.

Here is a sample run:

Input value to search for Amicable numbers: 10000

Amicable pairs found:
(220, 284)
(1184, 1210)
(2620, 2924)
(5020, 5564)
(6232, 6368)


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us