Perfect Numbers X89384


Statement
 

pdf   zip

An integer nn greater than zero is perfect if its equal to the sum of its divisors (except itself). Therefore, 66 is perfect since the sum of its divisors (but itself) is 1+2+3=61 + 2 + 3 = 6. In contrast, 88 is not perfect since 1+2+4=71 + 2 + 4 = 7 which is diferent from 88.

Write a function @is_perfect_number(n)@ that given the integer number nn greater than zero determines if nn is perfect or not.

Observation

Until 2016 only 49 perfect numbers were known! Probably the same number that are known nowadays!

Sample session

Sample session
>>> is_perfect_number(6)
True
>>> is_perfect_number(8)
False
>>> is_perfect_number(28)
True
>>> is_perfect_number(496)
True
>>> is_perfect_number(1)
False
Information
Author
InfBesos
Language
English
Other languages
Catalan Spanish
Official solutions
Python
User solutions
Python