Question: Assume that you've been asked to write an application that determines whether a number is perfect. A perfect number is a positive integer that is

Assume that you've been asked to write an application that determines whether a number is perfect. A perfect number is a positive integer that is equal to the sum of it's divisors (excluding itself). The first perfect number is 6. It is divisible by 1, 2 and 3. The sum of those numbers is 6.

For example, when the user enters 4 for the number:

4 is divisible by 1 so the sum = 1 4 is divisible by 2 so the sum is 1 + 2 or 3 4 is not divisible by 3 so the sum stays the same 4 is the number we started with so we don't divide by 4 and the sum stays the same 4 is the number and 3 is the sum so the number is not a perfect number

An algorithm in pseudocode is given below.

In dotnetfiddle.net or Visual Studio, translate the algorithm into syntactically correct C# code, using Main method.

Algorithm:

display instructions get number sum = 0 for each divisor between 1 and number - 1 if number is divisible by divisor then sum = sum + divisor end if end for loop if sum = number then display It's perfect else display It's NOT perfect end if

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!