Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in c++ that asks the user for input for two integer values: startval, and endval. The program will then find all Perfect

Write a program in c++ that asks the user for input for two integer values: startval, and endval. The program will then find all Perfect Numbers that fall between startval and endval. A perfect number is a number equal to the sum of all its proper divisors (divisors smaller than the number) including 1. The number 6 is the smallest perfect number; because it is the sum of its divisors 1, 2, and 3 (1+2+3 = 6). The next perfect number is 28 (28 = 1+2+4+7+14). The search for the Perfect Number will require two loops (nested). The outer loop will step thru the range of numbers between startval and endval. The inner loop will step thru the values from 1 to (outerval/2) to determine the factors of the number.

Write and use a function called isAFactor that accepts two int args, and determines if the second number is a factor of the first. It should return a bool value.

When a number is found, print out a message:

X is a Perfect Number.

If no Perfect Numbers can be found in the given range, print the message:

No Perfect Numbers found between x and y

.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

What are M1 and M2? How does the Fed alter M1 and M2?

Answered: 1 week ago

Question

28. Explain the differences between inclusive and exclusive cache.

Answered: 1 week ago