How does Python determine the Abundant Number?
This article describes how to use Python to determine the Abundant Number. Share it with you for your reference. The details are as follows:
Abundant Number is a special natural number. The sum of all positive values except itself is greater than itself.
Introduction see Baidu Encyclopedia: http://baike.baidu.com/view/1596350.htm
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# Checks if a number is abundant or not # An abundant number is the number of which sum # Factors (including itself) is greater than twice the number Def abundant (n ): Sum_factors = 0 For I in range (1, n + 1 ): If n % I = 0: # Finds out the factors F = I Sum_factors + = f If sum_factors> 2 * n: # Condition for abundant number Print "This is an Abundant Number! " Else: Print "This is not an Abundant Number! " |
I hope this article will help you with Python programming.