Ask your own question, for FREE!
Computer Science 22 Online
OpenStudy (anonymous):

how to write a c++ program which given an integer n, classifies it as "perfect", "abundant" or "deficient. a number is perfect if the sum of its divisor (excluding the number) is equal to the number eg. 6. a number is abundant is if the sum of its divisor (excluding the number is greater than the number eg 12?

OpenStudy (anonymous):

Here's a function for perfect numbers: int perfect(int number) { int factor=1, sum=0; while(number>1){ if(number%factor==0){ sum+=factor; } factor++; if(factor>=number)break; } if(sum==number)return true; else return false; }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!