# perfect integers up to 100

• 03-23-2002
Unregistered
perfect integers up to 100
well all im trying to do is get the perfect factor from 1-100 so why the hell does this crash :(

and what is a boolean function since i am supposed to make IsPerfect() a boolean function

Code:

```#include <iostream.h> //------------------------------------------------------------------- void IsPerfect() {         int count,totalfactors,perfect=0;         for(count=0;count<=100;count++)         {                 int count2;                 totalfactors=0;                 for(count2=0;count2<=count;count2++)                 {                         if(((count%count2)==0)&&(count!=count2))                         {                                 totalfactors+=count2;                         }                 }                                 if(totalfactors==(count2+1))                 {                         perfect++;                 }         }         cout<<totalfactors; } //------------------------------------------------------------------- int main() {         IsPerfect();         return (0); }```
• 03-23-2002
golfinguy4
A) Try not to declare variables inside a loop. Instead, declare them before the loop.

B) A boolean function is a function that returns a boolean value (true or false). False is normally represented as 0, and true is normally represented as 1 (sometimes any non zero value).
• 03-23-2002
Unregistered
you have IsPerfect() declared as a void function, it should be:

bool IsPerfect();
• 03-24-2002
Unregistered
Quote:

Originally posted by golfinguy4
A) Try not to declare variables inside a loop. Instead, declare them before the loop.

B) A boolean function is a function that returns a boolean value (true or false). False is normally represented as 0, and true is normally represented as 1 (sometimes any non zero value).

:| well i did that and its still crashing when running :(
• 03-24-2002
*ClownPimp*
1 = 1
1 + 3 = 4
1 + 3 + 5 = 9
1 + 3 + 5 + 7 = 16
1 + 3 + 5 + 7 + 9 = 25
1 + 3 + 5 + 7 + 9 + 11 = 36
.
.
.
1 + 3 + 5 +... + n-1 + n = nth perfect number
• 03-24-2002
Unregistered
Quote:

Originally posted by *ClownPimp*
1 = 1
1 + 3 = 4
1 + 3 + 5 = 9
1 + 3 + 5 + 7 = 16
1 + 3 + 5 + 7 + 9 = 25
1 + 3 + 5 + 7 + 9 + 11 = 36
.
.
.
1 + 3 + 5 +... + n-1 + n = nth perfect number

i want perfect factors from 1-100

so 1+2+3=6

anywyas nm all i got it to work :P