Python判断Abundant Number Python判断Abundant Number的方法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Python判断Abundant Number Python判断Abundant Number的方法

小卒过河   2021-03-21 我要评论
想了解Python判断Abundant Number的方法的相关内容吗,小卒过河在本文为您仔细讲解Python判断Abundant Number的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Python,判断,Abundant,Number,下面大家一起来学习吧。

本文实例讲述了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程序设计有所帮助。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们