While I agree that you should do your own homework, I assume that its

a Java assignment and not a Math one ! therefore a little hint wont

hurt. Euclid had come up with an algorithm to generate perfect

numbers. You can find more details here:

http://www-gap.dcs.st-and.ac.uk/~his...umbers.html#s1
This extract should help though:

There exists an elegant and sure method of generating these numbers,

which does not leave out any perfect numbers and which does not

include any that are not; and which is done in the following way.

First set out in order the powers of two in a line, starting from

unity, and proceeding as far as you wish: 1, 2, 4, 8, 16, 32, 64, 128,

256, 512, 1024, 2048, 4096; and then they must be totalled each time

there is a new term, and at each totalling examine the result, if you

find that it is prime and non-composite, you must multiply it by the

quantity of the last term that you added to the line, and the product

will always be perfect. If, otherwise, it is composite and not prime,

do not multiply it, but add on the next term, and again examine the

result, and if it is composite leave it aside, without multiplying it,

and add on the next term. If, on the other hand, it is prime, and

non-composite, you must multiply it by the last term taken for its

composition, and the number that results will be perfect, and so on as

far as infinity.

Good luck !

Ian