Program to Check if a Number is an Abundant Number in Python

Abundant Number

An abundant number is a number for which the sum of its proper divisors is greater than the number itself. For example, 12 is an abundant number because its divisors (1, 2, 3, 4, 6) sum to 16, which is greater than 12.

We will explore a method to check if a given number is an abundant number using Python programming.

Method: Using a for Loop

We iterate through all numbers less than the given number to find its divisors and sum them up.

def is_abundant(num):
    sum_divisors = sum(i for i in range(1, num // 2 + 1) if num % i == 0)
    return sum_divisors > num

# Get user input
num = int(input("Enter a number: "))

if is_abundant(num):
    print(f"{num} is an Abundant number")
else:
    print(f"{num} is not an Abundant number")
            

Output:

Enter a number: 12
12 is an Abundant number
Easy aceess next quctions
Getting Started

Positive or Negative number: C C++ Java Python

Even or Odd number: C C++ Java Python

Sum of First N Natural numbers: C C++ Java Python

Sum of N natural numbers: C C++ Java Python

Sum of numbers in a given range: C C++ Java Python

Greatest of two numbers: C C++ Java Python

Greatest of the Three numbers: C C++ Java Python

Leap year or not: C C++ Java Python

Prime number: C C++ Java Python

Prime number within a given range: C C++ Java Python

Sum of digits of a number: C C++ Java Python

Reverse of a number: C C++ Java Python

Palindrome number: C C++ Java Python

Armstrong number: C C++ Java Python

Armstrong number in a given range: C C++ Java Python

Harshad number: C C++ Java Python

Abundant number: C C++ Java Python

Friendly pair: C C++ Java Python