Question: Write a function that will read one integer from the command prompt. Your second function will decide whether the entered number is Perfect Number
Write a function that will read one integer from the command prompt. Your second function will decide whether the entered number is Perfect Number and Harmonic Divisor Number. The input must be a natural number. Perfect Number is the number at which the sum of all natural number divisor of a natural number n is equal to itself. (1 included, not including itself). Harmonic Divisor Number or Ore Number is a positive integer whose divisors have a harmonic mean that is an integer. Let the function continue working until it gets the input then end the program. Function prototype is void decide_perfect_harmonic_number() Example: Please enter input number: 6 Natural Number Divisors: 1, 2, 3, 6 Is Perfect Number? : Yes Hint: 1+2+3 = 6 and input 6. That's why it's the perfect number. Is Harmonic Divisor Number?: Yes Hint: Number 6 has the four divisors. Their harmonic mean is an integer: 4/ ((1/1)+ (1/2) + (1/3) + (1/6)) = 2 Please enter input number: 28 Natural Number Divisors: 1, 2, 4, 7, 14, 28 Is Perfect Number? : Yes Hint: 1+2+4+7+ 14 = 28 and input 28. That's why it's the perfect number. Is Harmonic Divisor Number?: Yes Hint: Number 28 has the six divisors. Their harmonic mean is an integer: 6/((1/1)+ (1/2) + (1/4) + (1/7) + (1/14) + (1/28) = 2 Please enter input number: 15 Natural Number Divisors: 1, 3, 5, 15 Hint: 1+ 3 + 5 = 9 but input 15. That's why it's not the perfect number. Is Perfect Number? : No Is Harmonic Divisor Number? : No Hint: Number 15 has the four divisors. Their harmonic mean is not an integer: 4 / ((1/1) + (1/3) + (1/5) + (1/15)) = 1.6
Step by Step Solution
3.42 Rating (139 Votes )
There are 3 Steps involved in it
The following pseudocode shows a function that will read one integer from the command prompt and det... View full answer
Get step-by-step solutions from verified subject matter experts
