I think this is a homework problem.....I did the coding and the first 4 perfect numbers are:
The perfect number is 6
The perfect number is 28
The perfect number is 496
The perfect number is 8128
Anyways, I will not give away the solution and rob you of your valuable education, however I will give the pseudo code......hope you can do the rest.....
class name
{
public static void main(String[] args)
{
initialize a count variable to 0 this will help you to count to first 4 perfect numbers
use for loop to check first 10000 numbers from which to get the first 4 perfect numbers starting from i=1
{
initialize sum variable
use for loop from variable j=1 to check till i
{
check divisibility
find sum of j's if i is divisble by j
}
use if statement to check for perfect number
and if count is less than 5
{
print the perfect number and increase count by one
}
}
}
}