A perfect number is an integer p>1 such that the sum of the positive divisors of
ID: 3620728 • Letter: A
Question
A perfect number is an integer p>1 such that the sum of the positive divisors of p equals p. For example, 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 to write to the file perfect.out all perfect numbers between 1 and a specied named integer constant LIMIT. For the purposes of the assignment, set the value of LIMIT to 10000.
The program is to define and use the following two functions:
int sum_of_positive_divisors(int number)
that calculates and returns the sum of all positive divisors of the integer argument number; candidate divisors of number range from 1 to number / 2. sum_of_positive_divisors() will only be called by is_perfect().
bool is_perfect(int number)
is a predicate (a boolean-valued function) that returns true iff the integer argument number is a perfect number and false otherwise. is_perfect() will call
sum_of_positive_divisors(); is_perfect() will only be called by main().