This example describes Python's method of judging abundant number. Share to everyone for your reference. Specific as follows:
Abundant number, translated into: surplus (also known as abundance, excess number abundant numbers) is a special natural number, except that it itself is the approximate and greater than itself.
Introduction See Baidu Encyclopedia: http://baike.baidu.com/view/1596350.htm
#Checks If a number is abundant or not#an abundant number are the number of which sum of#factors (including itself) is great Er than twice the numberdef abundant (n): sum_factors=0 for i in range (1,n+1): if n%i==0: #finds out the FA Ctors f=i sum_factors + f if sum_factors>2*n: #condition for abundant number print Abundant number! " else: print "This isn't an abundant number!"
Hopefully this article will help you with Python programming.