1 Replies - 2854 Views - Last Post: 04 November 2012 - 10:09 AM

#1 atik97   User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Abundant Number

Posted 08 March 2009 - 10:18 AM

Description: 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.
#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!"





Is This A Good Question/Topic? 0
  • +

Replies To: Abundant Number

#2 TechsterAmAn   User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 0
  • Joined: 01-November 12

Re: Abundant Number

Posted 04 November 2012 - 10:09 AM

no need to save i in f and then add to sum_factors. just sum_factors += i should suffice.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1