Sponsored Link •
|
Advertisement
|
Advertisement
|
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.
Message:
Hey, here u go with some kind of a pseudo code. I guess rajeev's solution would work,except that it just looks for that number alone and not for all numbers in the range. To make it simple : // increament by 1 if inputvalue is odd for int(i=1;number/2;i++){ // loop through hashtable for each key(1). // U are never bound to get a duplication in this because the keys are unique... > 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 Amicable.java, 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: > > Amicable pairs found:
Replies: |
Sponsored Links
|