Python Program to check Abundant Number

Check Whether or Not the Number is an Abundant Number in Python

Given an integer input as the number, the objective is to check whether or the given integer number is an Abundant Number or not. Therefore, we’ll write a program to Check Whether or Not the Number is an Abundant Number in Python Language.

Example
Input : 21
Output : It's not an Abundant Number. 
abundant or not in python

Check Whether or Not the Number is an Abundant Number in Python Language

Given an integer input the objective is to check whether or not the given integer is an Abundant Number. To do so we’ll use loop to find the factors of the number except the number itself and sum them all up. We’ll check Whether the number is lower or greater than the sum. For a Number to be classified as Abundant, the sum of it’s factors must be greater than the number itself. Here are the method’s we’ll be using to Check Whether or Not the Number is an Abundant Number in Python Language,

  • Method 1: Using Range until Number
  • Method 2: Using Range until Sqrt( Number )

We’ll discuss the above mentioned methods in detail in the upcoming sections. Do check out the blue box given below for better understanding of the above mentioned questions.

Method 1: Using Range until Number

Python Code

Run
n = 12

sum=1 # 1 can divide any number 

for i in range(2,n):
  if(n%i==0):    #if number is divisible by i add the number 
   sum=sum+i

if(sum>n):
  print(n,'is Abundant Number')

else:
  print(n,'is not Abundant Number')

Output

12 is Abundant Number

Method 2: Using Range until Sqrt( Number )

Python Code

Run
import math
n = 12
sum=1 # 1 can divide any number 
i=2

while(i<=math.sqrt(n)): 
  if(n%i==0): 
#if number is divisible by i add the number 
    if(n//i==i): 
# if quotient is equal to divisor add only one of them 
      sum=sum+i 
    else: 
        sum=sum + i + n/i 
        i=i+1 
    if(sum>n):
        print(n,"is Abundant Number")
    else:
        print(n,"is not Abundant Number")

Output

12 is Abundant Number

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

10 comments on “Python Program to check Abundant Number”


  • Abhishek

    # Try This
    def factors_sum(n):
    s=0
    for i in range(1,n//2+1):
    if n%i==0:
    s+=i
    return s
    n=int(input())
    print(f”Factors Sum: {factors_sum(n)}”)
    print(“Abundant Number” if factors_sum(n)>n else “Not Abundant Number”)


  • Sangram

    N = 12
    ls = [i for i in range(1, N) if N % i == 0]
    print(f”{N} is AbundantNumber” if sum(ls) > N else “Flase”)


  • D

    a=[]
    n=int(input())
    for i in range(1,n):
    if n%i==0 :
    a.append(i)
    print(a)
    c=sum(a)
    if(c>n):
    print(‘abundant number’)
    else:
    print(‘not an abundant’)


  • RAJA

    n=int(input())
    s=n
    arr=[]
    for i in range(1, n):
    if n%i==0:
    arr.append(i)
    sum1=sum(arr)
    if sum1>n:
    print(‘It is an abundant number’)
    else:
    print(‘It is not an abundant number’)


  • Srikanth

    # easy code
    n=int(input(“Enter a number : “))
    sum=0
    for i in range(1,n):
    if n%i==0:
    sum=sum+i
    print(“sum is”,sum)
    print(“Input is ” , n)
    if sum>n:
    print(“Abandant Number”)
    else:
    print(“Not abandant number “)


    • Pavan

      def abundant(x):
      y=[i for i in range(1,x) if(x%i==0)]
      print(‘ abundant’ if(sum(y)>x) else ‘ not abundant’)
      abundant (12)


  • Vishnukant

    x=int(input())
    sum=0
    for i in range(1,x):
    if x%i==0:
    sum=sum+i
    if sum>x:
    print(“yes”)
    else:
    print(“no”)


  • Bibhudutta

    n=int(input())
    sum=0

    for i in range(1,n):
    if(n%i==0):
    sum=sum+i

    if(sum>n):
    print(‘Abundant Number’)
    else:
    print(‘Not Abundant Number’)


  • Sonal

    num=int(input(“Enter the number “))
    sum=0
    for i in range(1,num):
    if num%i==0:
    sum+=i
    else:
    continue
    if sum>num:
    print(num,”is an Abundant Number”)
    else:
    print(num,”is not an Abundant Number”)


  • Abhishek

    n=int(input(“Enter the number:”))
    sum=0
    for i in range(1,n):
    a=n%i
    if(a==0):
    sum=sum+i
    if(sum>n):
    print(“It is Abundant”)
    else:
    print(“It is Not”)