Python判断Abundant Number的方法

作者:小卒过河 时间:2023-10-30 02:25:30 

本文实例讲述了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,判断
0
投稿

猜你喜欢

  • Python使用TextRank算法提取关键词

    2021-05-31 07:29:44
  • php实现xml与json之间的相互转换功能实例

    2023-11-22 05:38:00
  • 超越MYSQL,ACCESS复合承载

    2008-12-09 13:31:00
  • python编程使用PyQt创建UE蓝图

    2023-11-20 14:24:58
  • python argparse的使用步骤(全网最全)

    2023-06-14 01:13:45
  • asp提高首页性能的一个技巧

    2008-04-05 06:54:00
  • Python基于机器学习方法实现的电影推荐系统实例详解

    2023-09-13 17:13:41
  • php版淘宝网查询商品接口代码示例

    2023-11-14 12:01:54
  • php隐藏IP地址后两位显示为星号的方法

    2023-08-16 13:05:17
  • python获取代码运行时间的实例代码

    2023-11-04 02:25:10
  • 在win和Linux系统中python命令行运行的不同

    2023-08-03 05:16:22
  • XML DOM介绍和例子

    2007-10-15 20:23:00
  • PHP微信开发之有道翻译

    2023-11-22 01:08:19
  • Python3.5迭代器与生成器用法实例分析

    2022-11-03 14:50:47
  • ASP程序代码执行时间统计类

    2007-10-15 12:45:00
  • 数学公式“四又二分之一”

    2009-01-14 20:03:00
  • 解决Python logging模块无法正常输出日志的问题

    2023-10-03 17:04:25
  • ORACLE常用数值函数、转换函数、字符串函数

    2009-11-21 09:31:00
  • MySQL Explain命令用于查看执行效果

    2009-02-27 15:30:00
  • ASP代理采集的核心函数代码

    2010-01-02 20:43:00
  • asp之家 网络编程 m.aspxhome.com