Python判断Abundant Number的方法,pythonabundant
Python判断Abundant Number的方法,pythonabundant
本文实例讲述了Python判断Abundant Number的方法。分享给大家供大家参考。具体如下:
Abundant Number,中文译成:盈数(又称 丰数, 过剩数abundant number)是一种特殊的 自然数,除去它本身以外的一切正约数的和大于它本身。
介绍见百度百科: http://baike.baidu.com/view/1596350.htm
#Checks if a number is abundant or not #An abundant number is the number of which sum of #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!"
希望本文所述对大家的Python程序设计有所帮助。
相关内容
- Python实现简单HTML表格解析的方法,pythonhtml表格解析
- Python本地与全局命名空间用法实例,python全局命名空间
- Python读取键盘输入的2种方法,python键盘输入2种
- Python实现比较两个列表(list)范围,pythonlist
- Python 3.x 新特性及10大变化,python3.x
- 搞笑的程序猿:看看你是哪种Python程序员,python程序员
- Python中unittest模块做UT(单元测试)使用实例,pythonun
- Windows下实现Python2和Python3两个版共存的方法,python2py
- Python2中的raw_input() 与 input(),python2raw_input
- 在Linux下使用Python的matplotlib绘制数据图的教程,python
评论关闭