Question: Python Problem 1 A positive integer m greater than 1 is said to be a magic number if the sum of all its divisors (other

 Python Problem 1 A positive integer m greater than 1 is said to be a magic number if the sum of all its divisors (other than m) equals m. For example, 6 is a magic number because 1 + 2 + 3 = 6, and 28 is a magic number because 1 + 2 + 4 + 7 + 14 = 28, whereas 15 is not a magic number because 1 + 3 + 5 = 9 = 15, and 24 is not a magic number because 1 + 2 + 3 + 4 + 6 + 8 + 12 = 36 = 24. 

In this program, please write two functions, as described below. Important note: Do not repeat code unnecessarily. If you have a function to carry out a specific task, call that function rather than repeating those lines of code.

(5 points) A function called magic list with a single parameter num. It returns a list of all magic numbers between 2 and num (inclusive). Note: There are not that many magic numbers out there!! To see a magic number other than 6 and 28, import your module in the Python shell and call magic list with parameter 500. To see the next magic number, you will need to go even higher (over 8000).

Here is a sample output:

 >>> magic_list(100) [6, 28]

After importing the problem1 module, I will call the magic list function to test problem1.py.

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!