# Perfect Numbers

Page 1 of 1

## 2 Replies - 20476 Views - Last Post: 06 October 2007 - 08:40 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=34755&amp;s=67072cff397dd18f46bcba7ba4dc9ea6&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 prezident

Reputation: 1
• Posts: 1
• Joined: 06-October 07

# Perfect Numbers

Posted 06 October 2007 - 02:36 AM

[size=4]
```public class PerfectNo
{

public void perfectNoGenerator()
{
System.out.println( "please enter a number to check :  ");
Scanner keyboard = new Scanner(System.in);
int no = keyboard.nextInt();

int counter = 0;
//int no = 1;
int sum;

do
{
no = no + 1;
sum = 0;

for (int i =1;i<=(no/2);i++)
{

if(no % i== 0)
{

sum = sum + i;
}

}

if(sum ==no)
{
counter = counter +1;

System.out.println( sum +" is a perfect number ");
}

} while(counter< 5);

}

public static void main(String [] args)
{	   PerfectNo jobj = new PerfectNo();
jobj.perfectNoGenerator();
}
}
```

This post has been edited by PennyBoki: 06 October 2007 - 01:25 PM

Is This A Good Question/Topic? 1

## Replies To: Perfect Numbers

### #2 chuck87

Reputation: 2
• Posts: 69
• Joined: 07-September 07

## Re: Perfect Numbers

Posted 06 October 2007 - 04:54 AM

As you mention in the topic this program checks if a number provided by the user is a perfect number.What I got after executing it is completely different
When I provided numbe 10 the output was
28 is a perfect number
496 is a perfect number
8128 is a perfect number

When provided number 3
6 is a perfect number
28 is a perfect number
496 is a perfect number
8128 is a perfect number

If I am not wrong this program shows numbers that are perfect numbers and also greater than the number provided.
So it doesn't check if a number provided is a perfect one

### #3 sl4ck3r

• D.I.C Regular

Reputation: 11
• Posts: 285
• Joined: 22-September 07

## Re: Perfect Numbers

Posted 06 October 2007 - 08:40 PM

search the forums we did a program like this a couple weeks ago.