Abundant Number Check

Check if sum of proper divisors exceeds the number.

IntermediatePhase 2 - Level 2: Number-based Looping LogicExample 14 of 14
abundant-number-check.py
1# Take number
2num = int(input("Enter a number: "))
3
4# Find sum of proper divisors
5divisor_sum = 0
6for i in range(1, num):
7 if num % i == 0:
8 divisor_sum += i
9
10# Check abundant
11if divisor_sum > num:
12 print("Abundant number")
13else:
14 print("Not an abundant number")

Output

Enter a number: 12
Abundant number

What's going on

Sum of proper divisors > number.

Key Concepts:

Find all proper divisors
Sum them
Compare with number