# Program to determine whether a given number is an abundant number

Program to determine whether a given number is an abundant number on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph, pattern, string etc.

## Program to determine whether a given number is an abundant number

The abundant number can be called as an excessive number and defined as the number for which the sum of its proper divisors is greater than the number itself.

A first abundant number is the integer 12 having the sum (16) of its proper divisors (1, 2, 3, 4, 6) which is greater than itself (12).

Examples: 12, 18, 20, 24, 30, 36

In this program, we have to check whether a given number is an abundant number using the algorithm given below.

### Algorithm

MAIN

• STEP 1: START
• STEP 2: ENTER n.
• STEP 3: if CheckAbundant(n) is true
then PRINT "yes"
else
PRINT "no".

CheckAbundant (n)

• STEP 1: START
• STEP 2: SET i= GetSum(n)
• STEP 3: if i>n
then RETURN true
else
RETURN false.

GetSum(n)

• STEP 1: START
• STEP 2: SET sum = 0
• STEP 3: REPEAT STEP 4 UNTIL i<=?n
• STEP 4: if n%i == 0
then
if(n/i==i)
sum=sum+i
else
sum =sum+i
sum= sum+n/i
• STEP 5: sum =sum - n
• STEP 6: RETURN sum

### Java program

```import  java.util.*;
public  class Abundant_number {
public static void main(String[] args) {
System.out.println("Enter the number?");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Abundant_number  a = new Abundant_number();
if(a.checkAbundant(n))
{
System.out.println("The number is Abundant.");
}
else
{
System.out.println("The number is not Abundant.");
}
}
public int getSum(int n)
{
int sum = 0;
for (int i=1; i<=Math.sqrt(n); i++)
{
if (n%i==0)
{
if (n/i == i)
sum = sum + i;
else
{
sum = sum + i;
sum = sum + (n / i);
}
}
}
sum = sum - n;
return sum;
}
public  boolean checkAbundant(int n)
{
return (getSum(n) > n);
}}
```

Output:

```Enter the number?
20
The number is Abundant
```

### C program

```# include <stdio.h>
# include <string.h>
# include <stdbool.h>
# include <math.h>
int getSum(int n)
{
int sum = 0;
for (int i=1; i<=sqrt(n); i++)
{
if (n%i==0)
{
if (n/i == i)
sum = sum + i;
else
{
sum = sum + i;
sum = sum + (n / i);
}
}
}
sum = sum - n;
return sum;
}
bool checkAbundant(int n)
{
return getSum(n) > n;
}
int main()
{
int n;
printf("Enter the number?");
scanf("%d",&n);
checkAbundant(n)? printf("The number is Abundant.\n") : printf("The number is not Abundant.\n");
return 0;
}
```

Output:

```Enter the number? 34
The number is not Abundant.
```

### Python Program:

```def is_abundant(n):
fctr_sum = sum([fctr for fctr in range(1, n) if n % fctr == 0])
return fctr_sum > n
a = int(input("Enter the number?"));
if is_abundant(a):
print("The number is Abundant.");
else:
print("The number is not Abundant.")

```

Output:

```Enter the number?24
The number is Abundant.
```

### C# program

```using System;
public class AbundantNumber {
public static int getSum(int n)
{
int sum = 0;
for (int i = 1; i <= (Math.Sqrt(n)); i++) {
if (n % i == 0) {
if (n / i == i)
sum = sum + i;

else
{
sum = sum + i;
sum = sum + (n / i);
}
}
}

sum = sum - n;
return sum;
}
static bool Abundant(int n)
{
return (getSum(n) > n);
}

public static void Main()
{
Console.WriteLine("Enter the number?");
int n = Convert.ToInt32(Console.ReadLine());
if(Abundant(n))
{
Console.WriteLine("The number is Abundant.");
}
else
{
Console.WriteLine("The number is not Abundant.");
}
}
}
```

Output:

```Enter the number?
67
The number is not Abundant.
```

### PHP Program

```<?php
echo "Enter the number?";
\$n=readline();
\$k = abundant(\$n) ? "The number is Abundant." : "The number is not Abundant.";
echo(\$k);
function value(\$n)
{
\$sum = 0;
for (\$i = 1; \$i <= sqrt(\$n); \$i++)
{
if (\$n % \$i == 0)
{
if (\$n / \$i == \$i)
\$sum = \$sum + \$i;
else
{
\$sum = \$sum + \$i;
\$sum = \$sum + (\$n / \$i);
}
}
}
\$sum = \$sum - \$n;
return \$sum;
}
function abundant(\$n)
{
return (value(\$n) > \$n);
}
?>
```

Output:

```Enter the number? 56
The number is Abundant.
```
Next Topic#

### Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf