 ### Program to check whether a number is Abundant number or not ### Select Articles

Program to check whether a number is Abundant number or not

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>

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>

Else, print "Not Abundant Number".

Program to check whether a number is an abundant number or not

C

// C program to check whether a number is an abundant number or not

#include

int main()

{

//fill the code

int num;

int temp;

scanf(“%d”,#);

int sum = 0;

for(int i = 1; i < num>

{

if(num % i == 0)

{

sum = sum + i;

}

}

if(num < sum>

printf(“Abundant Number”);

else

printf(“Not Abundant Number”);

return 0;

}

C++

// C++ program to check whether a number is an abundant number or not

#include

using namespace std;

int main()

{

//fill the code

int num;

int temp;

cin >> num;

int sum = 0;

for(int i = 1; i < num>

{

if(num % i == 0)

{

sum = sum + i;

}

}

if(num < sum>

cout << “Abundant Number”;

else

cout << “Not Abundant Number”;

return 0;

}

JAVA 8

// Java program to check whether a number is an abundant number or not

import java.util.*;

public class Main

{

public static void main(String[] args)

{

int num, temp;

Scanner sc = new Scanner(System.in);

num = sc.nextInt();

int sum = 0;

for(int i = 1; i < num>

{

if(num % i == 0)

{

sum = sum + i;

}

}

if(num < sum>

System.out.print(“Abundant Number”);

else

System.out.print(“Not Abundant Number”);

}

}

PYTHON 3

# Python program to check whether a number is an abundant number or not

num = int(input())

sum = 0

for i in range(1,num):

if(num % i == 0):

sum = sum + i

if(num < sum>

print(“Abundant Number”)

else:

print(“Not Abundant Number”)

OUTPUT

12

Abundant Number