丰沛数_不足数_完全数

因数的和比数字本身大的数称为丰沛数。

因数的和比数字本身小的数称为不足数。

完全数是一个整数:其因数之和(不含本身打因素)加起来就是数字本身。

 1 theNum = int(raw_input('Please input a number to check:'))
 2 
 3 divisor = 1
 4 sumOfDivisor = 0
 5 
 6 while divisor < theNum:
 7     if theNum % divisor == 0:
 8         print divisor,
 9         sumOfDivisor += divisor
10     divisor += 1
11 
12 print
13 
14 if sumOfDivisor == theNum:
15     print 'theNum', theNum, 'is perfect.'
16 else:
17     print 'theNum', theNum, 'is not perfect.'

 

posted @ 2015-09-22 23:36  berthua  阅读(1364)  评论(0编辑  收藏  举报