Number properties¶
The proper divisors of an integer number are defined as their positive divisors except for himself. It is said that a number is perfect if it is equal to the addition of its proper divisors. It is also said that a number is deficient if the addition of its proper divisors is less than itself, and it is said that it is abundant if this addition is greater than the number itself.
Save all functions into a file named properties.py.
Write the function
divisors()that given an integer number, returns the addition of its proper divisors. Examples:>>> divisors(496) 496 >>> divisors(13) 1 >>> divisors(945) 975
Note
More tests are provided in file
divisors.txtWrite the function
number_type()that given an integer number, returns a string with the values'abundant','deficient'or'perfect'depending on which of these types the given number is. This function must call the previous functiondivisors(). Examples:>>> number_type(496) 'perfect' >>> number_type(13) 'deficient' >>> number_type(945) 'abundant'
Note
More tests are provided in file
properties-1.txtIs is said that two integer numbers n and m are friends if the addition of the proper divisors of n is m and the addition of the proper divisors of m is n. Write the Boolean function
are_friends()that, given two integers, returnsTrueif they are friends andFalseotherwise. This function must call the previous functiondivisors(). Examples:>>> are_friends (220, 284) True >>> are_friends (113, 1546) False
Note
More tests are provided in file
properties-2.txt
Solution
A solution of these functions is provided in file properties.py