If someone could please help me...I'm learning how to use C++ but no matter how long I attempt this problem I cannot seem to get anywhere...if you could help with some input, I would be much appreciated...i ts the following...
* a perfect number has a sum of divisors equal to the number itself. The first
perfect number is 6, because the sum of its divisors (1,2,3) is equal to 6 itself.
* a deficient number has a sum of divisors less than the number itself. Therefore, 5 is a deficient number because the sum of its divisors (1) is less than 5.
* an abundant number has a sum of divisors more than the number itself. Therefore, 12 is an abundant number because the sum of its divisors (1,2,3,4,6) is more than 12.
Program Specifications
Your program will:
1. Your program takes a single input, the highest number to examine. Thus, if you enter 1000, you examine all the integers from 1 to 1000 (inclusive).
2. Every time a perfect number is found, that number is reported.
3. At the end of execution, a count of the three categories is provided for the numbers between 1 and the entered number. We will test the program on the interval 1 to 1000.
Assignment Notes:
The first problem is to find the divisors of a number. Think about two things. First, given any target number, how should I check if another number is a divisor of the target? You will find the % operator to be useful in this task.
Second, if I can find divisors, how can I determine if a number is perfect, deficient or abundant? How do I design a piece of program to make that decision? Look at the Overview above for the conditions and think about how to make that decision.
Third, how can use the above solutions and apply it to every number between 1 and the entered number?
* a perfect number has a sum of divisors equal to the number itself. The first
perfect number is 6, because the sum of its divisors (1,2,3) is equal to 6 itself.
* a deficient number has a sum of divisors less than the number itself. Therefore, 5 is a deficient number because the sum of its divisors (1) is less than 5.
* an abundant number has a sum of divisors more than the number itself. Therefore, 12 is an abundant number because the sum of its divisors (1,2,3,4,6) is more than 12.
Program Specifications
Your program will:
1. Your program takes a single input, the highest number to examine. Thus, if you enter 1000, you examine all the integers from 1 to 1000 (inclusive).
2. Every time a perfect number is found, that number is reported.
3. At the end of execution, a count of the three categories is provided for the numbers between 1 and the entered number. We will test the program on the interval 1 to 1000.
Assignment Notes:
The first problem is to find the divisors of a number. Think about two things. First, given any target number, how should I check if another number is a divisor of the target? You will find the % operator to be useful in this task.
Second, if I can find divisors, how can I determine if a number is perfect, deficient or abundant? How do I design a piece of program to make that decision? Look at the Overview above for the conditions and think about how to make that decision.
Third, how can use the above solutions and apply it to every number between 1 and the entered number?
Comment