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

5 comments on “Python Program to check 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 “)


  • 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”)