Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python3 to solve A proper divisor of a positive integer, n, is a positive integer, d, which divides evenly into n and is not

Using Python3 to solve

image text in transcribed

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 1+2+3+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

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

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

=+you think is being taxed when more money is printed? Why?

Answered: 1 week ago