A perfect number is an integer p>1 such that the sum of the positive divisors of
ID: 3620217 • Letter: A
Question
A perfect number is aninteger p>1 such that the sum of the positive divisors of p equals p. For ex-
ample, 6 is a perfect number since 1+2+3 = 6; 28 is a perfect number since
1+2+4+7+14 = 28.
Write a complete C++ program in perfect.cc to write to standard output
all perfect numbers between 1 and a specied named constant LIMIT. For the
purposes of the assignment, set the value of LIMIT to 10000.
const int LIMIT = 10000;
I think we are only supossed to use while and if statements. I know it has to do with the % operation but everything i have been trying doesn't work.
Explanation / Answer
#include using namespace std; const int LIMIT = 10000; int main() { int i,j,k,sum; i=1; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.