Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions