Question: Write a function isPerfect(). The function will have one integer parameters N. The function will display all the factors of N and their sum. The

 Write a function isPerfect(). The function will have one integer parameters

Write a function isPerfect(). The function will have one integer parameters N. The function will display all the factors of N and their sum. The function will return true if N is a perfect number, otherwise it will return false. A number N is a perfect number, if the sum of its factors from 1 to N-1 is equal to N. For example, if N is 6, then its factors are 1, 2, and 3. Their sum is equal to 6, therefore 6 is a perfect number. Write the main() function. Input two integers x and y. Assume x is less than y. Using a loop from x to y, only display the number that are the perfect numbers from x to y. Use the function isPerfect() to check if a number is a perfect number. At the end display the count of the prefect numbers.

Problem 5: Write a function isPerfect(). The function will have one integer parameters N. The function will display all the factors of N and their sum. The function will return true if N is a perfect number, otherwise it will return false. A number N is a perfect number, if the sum of its factors from 1 to N-1 is equal to N. For example, if N is 6, then its factors are 1, 2, and 3. Their sum is equal to 6, therefore 6 is a perfect number. Write the main() function, Input two integers x and y. Assume x is less than y. Using a loop from x to y, only display the number that are the perfect numbers from x to y. Use the function isPerfect()to check if a number is a perfect number. At the end display the count of the prefect numbers. Sample input/output: Enter two numbers: 1 30 6 is Perfect 28 is Perfect There are 2 Perfect numbers from 1 to 30 Enter two numbers: 1 500 6 is Perfect 28 is Perfect 96 is Perfect There are 3 Perfect numbers from 1 to 500

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!