Monday, July 14, 2008

Perfect Numbers and Prime Numbers! (Minor Project)

Please implement this method to determine whether a number is PERFECT!

For example: 6 is a perfect number because 6 = 1 + 2 + 3 (1, 2, 3 are divisors of 6)
28 is also a perfect number: 28 = 1 + 2 + 4 + 7 + 14

Make your method static and test it!

You need th % modulus operator to make this work.

The second part is to find all the prime numbers up to a certain number. For instance if a user enters in 5, you will find all the prime numbers up to 5. Would 5be included? Yes! It is prime. 1 is not prime. Create a new static method to determine all the prime numbers up to that point.

Here are some notes on the questions. Pseduocode to turn into code.

Due Friday July 18th, 2008.

No comments: