Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python 1. A proper divisor of a positive integer, n, is a positive integer, d, which divides evenly into n and is not equal

Using Python

image text in transcribed

1. A proper divisor of a positive integer, n, is a positive integer, d, which divides evenly into n and is not equal to n. For example, the proper divisors of 24 are 1, 2, 3, 4, 6, 8 and 12 while the proper divisors of 9 are 1 and 3 A number is said to be abundant if the sum of its proper divisors is greater than the number itself. For example, 24 is an abundant number because 123+4+6+8 12 36, which is greater than 24. A number is said to be deficient if the sum of its proper divisors is less than the number itself. For example, 9 is a deficient number because 1 +3 4, which is less than 9. A perfect number is a positive integer where the sum of its proper divisors is equal to the number For example, 6 is a perfect number because its proper divisors are 1, 2 and 3, and they sum to 6 Note that 1 is a deficient number because it has no proper divisors. Write a program that reads integers from the user until the user enters a value less than or equal to 0. For each entered integer (other than the value that is less than or equal to 0) your program should report whether the number is abundant, perfect, or deficient. Sample input and output is shown below. Values entered by the user are shown in bold Enter an integer (0 or less to quit): 6 That's a perfect number Enter an integer (0 or less to quit): 24 That's an abundant number Enter an integer (0 or less to quit): 9 That's a deficient number Enter an integer (0 or less to quit): 0 A second set of sample input and output is shown below: Enter an integer (0 or less to quit): 8 That's a deficient number Enter an integer (0 or less to quit):-6 Ensure that your program behaves in a reasonable manner if the first number entered is less than or equal to 0. The prompts and messages in your program should match the sample input and output. Moreover, ensure that your code is in a function that takes one parameter and return a value between 0 and -1 (-1: indicates it is deficient, 0: indicates it is abundant, and 1: indicates it is perfect). Your function should be called from main after user input is taken. User should be able to keep entering numbers until he/she press q. Further, make sure your code has proper comments

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_2

Step: 3

blur-text-image_3

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

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions