Question: A positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example,
A positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the perfect number since 6=1+2+3. The next is 28=1+2+4+7+12. There are four perfect numbers less than 10,000. Write a program that prints all these four numbers. (USE PYTHON) Your program should have a function called is_perfect that takes as input a positive integer and returns True if it is perfect and False otherwise. Modify the divisors(n) function you implemented from the previous lab. So it returns a list of divisors of number n. Use this function to do the rest.
Once you are done. Modify your program so that it looks for all perfect numbers smaller than 35 million. What do you notice? Assuming that your computer can do a billion instructions in a sec, can you figure out how long, roughly, will it take your computer to find the 5th perfect number (it is 33,550,336). Is the answer roughly: a couple of minutes, a couple of hours, a couple of days, weeks, months, years? What if you wanted to wait until it prints the 6th perfect number, which is 8,589,869,056?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
