Program to check whether a number is Abundant number or not is discussed here. An abundant number is a number for which the sum of its proper divisors is greater than the number itself.
Input & Output format:
- Input consists of 1 integer.
- If it is an Abundant number display Abundant Number or display Not Abundant Number.
Sample input:
12
Sample Output:
Abundant Number
Explanation:
The divisors of 12 are 1, 2, 3, 4 and 6.
The sum of divisors of 12 is 16.
12 < 16.Hence, 12 is an abundant number.
Algorithm to check whether a number is an abundant number or not
- Input a number from the user.
- Find the sum of its divisors.
- If sum < num, print "Abundant Number".
- Else, print "Not Abundant Number".
Program:
n=int(input())
list1=[]
for i in range(1,(n//2)+1):
if n%i==0:
list1.append(i)
if sum(list1)>n:
print("YES")
else:
print("NO")
Post a Comment