# Abundant Number

Here given code implementation process.

``````//C Program
//Check if a given number is abundant or not
#include <stdio.h>

// Function which is calculate sum of divisors in given number
int divisor_sum(int number)
{
int result = 0;

for (int i=1; i<= number/2; i++)
{
if (number%i==0)
{
//When number is divide by i
result += i;
}
}

return result;
}
//Function are show the result number is abundant or not
void is_abundant(int number)
{
//Check whether number divisor sum is greater than given number?
if(divisor_sum(number) > number)
{
//When Yes
printf("%d Is an Abundant Number\n",number);
}
else
{
//When No
printf("%d Is not a Abundant Number\n",number);
}
}

int main() {
//Test Cases
is_abundant(20);
is_abundant(11);
is_abundant(104);
return 0;
}```
```

#### Output

``````20 Is an Abundant Number
11 Is not a Abundant Number
104 Is an Abundant Number``````
``````/*
C++ Program
Check if a given number is abundant or not
*/
#include<iostream>

using namespace std;

class MyNumber {
public:

// Function which is calculate sum of divisors in given number
int divisor_sum(int number) {
int result = 0;
for (int i = 1; i <= number / 2; i++) {
if (number % i == 0) {
//When number is divide by i
result += i;
}
}
return result;
}
//Function are show the result number is abundant or not
void is_abundant(int number) {
//Check whether number divisor sum is greater than given number?

if (this->divisor_sum(number) > number) {
//When Yes

cout << number << " Abundant Number\n";
} else {
//When No

cout << number << " Is not a Abundant Number\n";
}
}
};
int main() {
MyNumber obj ;
// Test Case
obj.is_abundant(20);
obj.is_abundant(11);
obj.is_abundant(104);
return 0;
}```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number``````
``````/*
Java Program
Check if a given number is abundant or not
*/

public class MyNumber {

// Function which is calculate sum of divisors in given number
public int divisor_sum(int number)
{
int result = 0;

for (int i=1; i<= number/2; i++)
{
if (number%i==0)
{
//When number is divide by i
result += i;
}
}

return result;
}
//Function are show the result number is abundant or not
public void is_abundant(int number)
{
//Check whether number divisor sum is greater than given number?
if(divisor_sum(number) > number)
{
//When Yes
System.out.print(number+" Abundant Number\n");
}
else
{
//When No
System.out.print(number+" Is not a Abundant Number\n");
}
}
public static void main(String[] args) {

MyNumber obj = new MyNumber();
// Test Case
obj.is_abundant(20);
obj.is_abundant(11);
obj.is_abundant(104);
}
}```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number``````
``````/*
C# Program
Check if a given number is abundant or not
*/
using System;
public class MyNumber {

// Function which is calculate sum of divisors in given number
public int divisor_sum(int number) {
int result = 0;

for (int i = 1; i <= number / 2; i++) {
if (number % i == 0) {
//When number is divide by i
result += i;
}
}

return result;
}
//Function are show the result number is abundant or not
public void is_abundant(int number) {
//Check whether number divisor sum is greater than given number?
if (divisor_sum(number) > number) {
//When Yes
Console.Write(number + " Abundant Number\n");
} else {
//When No
Console.Write(number + " Is not a Abundant Number\n");
}
}
public static void Main(String[] args) {

MyNumber obj = new MyNumber();
// Test Case
obj.is_abundant(20);
obj.is_abundant(11);
obj.is_abundant(104);
}
}```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number``````
``````# Python 3 Program
# Java Program
class MyNumber :
# Function which is calculate sum of divisors in given number
def divisor_sum(self, number) :
result = 0
i = 1
while (i <= int(number / 2)) :
if (number % i == 0) :
#When number is divide by i
result += i

i += 1

return result

#Function are show the result number is abundant or not
def is_abundant(self, number) :
#Check whether number divisor sum is greater than given number?

if (self.divisor_sum(number) > number) :
print(number ," Abundant Number")
else :
print(number ," Is not a Abundant Number")

def main() :
obj = MyNumber()
obj.is_abundant(20)
obj.is_abundant(11)
obj.is_abundant(104)

if __name__ == "__main__":
main()```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number``````
``````# Ruby Program
# Check if a given number is abundant or not

class MyNumber
# Function which is calculate sum of divisors in given number
def divisor_sum(number)
result = 0
i = 1
while (i <= number / 2)
if (number % i == 0)
#When number is divide by i
result += i
end
i += 1
end
return result
end
#Function are show the result, number is abundant or not
def is_abundant(number)
#Check whether number divisor sum is greater than given number?

if (self.divisor_sum(number) > number)
print(number ," Abundant Number\n")
else
print(number ," Is not a Abundant Number\n")
end
end
end
def main()
obj = MyNumber.new()
obj.is_abundant(20)
obj.is_abundant(11)
obj.is_abundant(104)
end
main()```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number
``````
``````/*
Scala Program
Check if a given number is abundant or not
*/
class MyNumber {
// Function which is calculate sum of divisors in given number
def divisor_sum(number: Int): Int = {
var result: Int = 0;
var i: Int = 1;
while (i <= number / 2) {
if (number % i == 0) {
//When number is divide by i
result += i;
}
i += 1;
}
return result;
}
//Function are show the result number is abundant or not
def is_abundant(number: Int): Unit = {
//Check whether number divisor sum is greater than given number?

if (this.divisor_sum(number) > number) {
print(s"\$number Abundant Number\n");
} else {
print(s"\$number Is not a Abundant Number\n");
}
}
}
object Main {
def main(args: Array[String]): Unit = {
var obj: MyNumber = new MyNumber();
obj.is_abundant(20);
obj.is_abundant(11);
obj.is_abundant(104);
}
}```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number``````
``````/*
Swift 4 Program
Check if a given number is abundant or not
*/
class MyNumber {
// Function which is calculate sum of divisors in given number
func divisor_sum(_ number: Int) -> Int {
var result: Int = 0;
var i: Int = 1;
while (i <= number / 2) {
if (number % i == 0) {
//When number is divide by i
result += i;
}
i += 1;
}
return result;
}
//Function are show the result number is abundant or not
func is_abundant(_ number: Int) {
//Check whether number divisor sum is greater than given number?

if (self.divisor_sum(number) > number) {
print(number ," Abundant Number");
} else {
print(number ," Is not a Abundant Number");
}
}
}
func main() {
let obj: MyNumber = MyNumber();
obj.is_abundant(20);
obj.is_abundant(11);
obj.is_abundant(104);
}
main();```
```

#### Output

``````20  Abundant Number
11  Is not a Abundant Number
104  Abundant Number``````
``````<?php
/*
Php Program
Check if a given number is abundant or not
*/
class MyNumber {
// Function which is calculate sum of divisors in given number

public 	function divisor_sum(\$number) {
\$result = 0;
for (\$i = 1; \$i <= intval(\$number / 2); \$i++) {
if (\$number % \$i == 0) {
//When number is divide by i
\$result += \$i;
}
}
return \$result;
}
//Function are show the result number is abundant or not

public 	function is_abundant(\$number) {
//Check whether number divisor sum is greater than given number?

if (\$this->divisor_sum(\$number) > \$number) {
//When Yes

echo(\$number ." Abundant Number\n");
} else {
//When No

echo(\$number ." Is not a Abundant Number\n");
}
}
};

function main() {
\$obj = new MyNumber();
// Test Case

\$obj->is_abundant(20);
\$obj->is_abundant(11);
\$obj->is_abundant(104);
}
main();```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number``````
``````/*
Node Js Program
Check if a given number is abundant or not
*/
class MyNumber {
// Function which is calculate sum of divisors in given number
divisor_sum(number) {
var result = 0;
for (var i = 1; i <= parseInt(number / 2); i++) {
if (number % i == 0) {
//When number is divide by i
result += i;
}
}
return result;
}
//Function are show the result number is abundant or not
is_abundant(number) {
//Check whether number divisor sum is greater than given number?

if (this.divisor_sum(number) > number) {
//When Yes

process.stdout.write(number + " Abundant Number\n");
} else {
//When No

process.stdout.write(number + " Is not a Abundant Number\n");
}
}
}

function main(args) {
var obj = new MyNumber();
// Test Case
obj.is_abundant(20);
obj.is_abundant(11);
obj.is_abundant(104)
}
main();```
```

#### Output

``````20 Abundant Number
11 Is not a Abundant Number
104 Abundant Number``````

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.