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 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 500Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started