Python method for judging abundant number

Source: Internet
Author: User
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.