# Disarium Number

Here given code implementation process.

``````//C Program
//Check if a given number is disarium or not
#include <stdio.h>
#include <math.h>
// count the number of digits in number
int digit_length(int number)
{
int size = 0;

while (number!=0)
{
number/=10;

size++;
}
return size;
}

// Function to check whether a number is disarium or not
void is_disarium(int number)
{
//set initial values
int sum = 0;

//Find the length of given number
int size = digit_length(number);

int auxiliary = number;

while (number!=0)
{
// Get the last digit
int digit = number%10;

sum = sum + pow(digit,size);

//Remove last digit
number/=10;

//Reduce the length size
size--;
}

if(sum == auxiliary)
{
printf("%d Is Disarium Number\n", auxiliary);
}
else
{
printf("%d Is not Disarium Number\n", auxiliary);
}
}

//Driver code to check if number is disarium or not
int main()
{
//Test Case
is_disarium(89);
is_disarium(72);
is_disarium(9);
return 0;
}
```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number``````
``````#include<iostream>
#include <math.h>
using namespace std;
/*
C++ Program
Check if a given number is disarium or not
*/
class MyNumber {
public:

//Count the number of digits in number
int digit_length(int number) {
int size = 0;
while (number != 0) {
number /= 10;
size++;
}
return size;
}
// Function to check whether a number is disarium or not
void is_disarium(int number) {
//set initial values
int sum = 0;
//Find the length of given number
int size = this->digit_length(number);
int auxiliary = number;
while (auxiliary != 0) {
// Get the last digit
int digit = auxiliary % 10;
sum = sum + pow(digit,size);
//Remove last digit
auxiliary /= 10;
//Reduce the length size
size--;
}
if (sum == number) {
cout << number << " Is Disarium Number\n";
} else {
cout << number << " Is not Disarium Number\n";
}
}
};
int main() {
MyNumber obj;
// Test Case
obj.is_disarium(89);
obj.is_disarium(72);
obj.is_disarium(9);
return 0;
}```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number``````
``````/*
Java Program
Check if a given number is disarium or not
*/

public class MyNumber {

//Count the number of digits in number
public int digit_length(int number)
{
int size = 0;

while (number!=0)
{
number/=10;

size++;
}
return size;
}

// Function to check whether a number is disarium or not
public void is_disarium(int number)
{
//set initial values
int sum = 0;

//Find the length of given number
int size = digit_length(number);

int auxiliary = number;

while (auxiliary!=0)
{
// Get the last digit
int digit = auxiliary%10;

sum =  sum + (int)Math.pow(digit,size);

//Remove last digit
auxiliary/=10;

//Reduce the length size
size--;
}

if(sum == number)
{
System.out.print(number+" Is Disarium Number\n");
}
else
{
System.out.print(number+" Is not Disarium Number\n");
}
}
public static void main(String[] args) {

MyNumber obj = new MyNumber();
// Test Case

obj.is_disarium(89);
obj.is_disarium(72);
obj.is_disarium(9);
}
}```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number``````
``````/*
C# Program
Check if a given number is disarium or not
*/
using System;
public class MyNumber {

//Count the number of digits in number
public int digit_length(int number) {
int size = 0;

while (number != 0) {
number /= 10;

size++;
}
return size;
}

// Function to check whether a number is disarium or not
public void is_disarium(int number) {
//set initial values
int sum = 0;

//Find the.Length of given number
int size = digit_length(number);

int auxiliary = number;

while (auxiliary != 0) {
// Get the last digit
int digit = auxiliary % 10;

sum = sum + (int) Math.Pow(digit, size);

//Remove last digit
auxiliary /= 10;

//Reduce the.Length size
size--;
}

if (sum == number) {
Console.Write(number + " Is Disarium Number\n");
} else {
Console.Write(number + " Is not Disarium Number\n");
}
}
public static void Main(String[] args) {

MyNumber obj = new MyNumber();
// Test Case

obj.is_disarium(89);
obj.is_disarium(72);
obj.is_disarium(9);
}
}```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number``````
``````# Python 3 Program
# Check if a given number is disarium or not

class MyNumber :
#Count the number of digits in number
def digit_length(self, number) :
size = 0
while (number != 0) :
number = int(number/ 10)
size += 1

return size

# Function to check whether a number is disarium or not
def is_disarium(self, number) :
#set initial values
sum_num = 0
#Find the length of given number
size = self.digit_length(number)
auxiliary = number
while (auxiliary != 0) :
# Get the last digit
digit = auxiliary % 10

sum_num = sum_num +  digit**size

#Remove last digit
auxiliary=int(auxiliary / 10)
#Reduce the length size
size -= 1

if (sum_num == number) :
print(number ," Is Disarium Number")
else :
print(number ," Is not Disarium Number")

def main() :
obj = MyNumber()
# Test Case
obj.is_disarium(89)
obj.is_disarium(72)
obj.is_disarium(9)

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

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number``````
``````# Ruby Program
#  Check if a given number is disarium or not

class MyNumber
#Count the number of digits in number
def digit_length(number)
size = 0
while (number != 0)
number /= 10
size += 1
end
return size
end
# Function to check whether a number is disarium or not
def is_disarium(number)
#set initial values
sum = 0
#Find the length of given number
size = self.digit_length(number)
auxiliary = number
while (auxiliary != 0)
# Get the last digit
digit = auxiliary % 10
sum = sum + digit**size
#Remove last digit
auxiliary /= 10
#Reduce the length size
size -= 1
end
if (sum == number)
print(number ," Is Disarium Number\n")
else
print(number ," Is not Disarium Number\n")
end
end
end
def main()
obj = MyNumber.new()
# Test Case
obj.is_disarium(89)
obj.is_disarium(72)
obj.is_disarium(9)
end
main()```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number
``````
``````/*
Scala Program
Check if a given number is disarium or not
*/
class MyNumber {
//Count the number of digits in number
def digit_length(value: Int): Int = {
var size: Int = 0;
var number: Int = value;
while (number != 0) {
number /= 10;
size += 1;
}
return size;
}
// Function to check whether a number is disarium or not
def is_disarium(number: Int): Unit = {
//set initial values
var sum: Int = 0;
//Find the length of given number
var size: Int = this.digit_length(number);
var auxiliary: Int = number;
while (auxiliary != 0) {
// Get the last digit
var digit: Int = auxiliary % 10;
sum = sum + (scala.math.pow(digit, size)).toInt;
//Remove last digit
auxiliary /= 10;
//Reduce the length size
size -= 1;
}
if (sum == number) {
print(s"\$number Is Disarium Number\n");
} else {
print(s"\$number Is not Disarium Number\n");
}
}
}
object Main {
def main(args: Array[String]): Unit = {
var obj: MyNumber = new MyNumber();
// Test Case
obj.is_disarium(89);obj.is_disarium(72);obj.is_disarium(9);
}
}```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number``````
``````/*
Swift 4 Program
Check if a given number is disarium or not
*/
import Foundation
class MyNumber {
//Count the number of digits in number
func digit_length(_ value: Int) -> Int {
var size: Int = 0;
var number: Int = value;
while (number != 0) {
number /= 10;
size += 1;
}
return size;
}
// Function to check whether a number is disarium or not
func is_disarium(_ number: Int) {
//set initial values
var sum: Int = 0;
//Find the length of given number
var size: Int = self.digit_length(number);
var auxiliary: Int = number;
var digit: Int=0;
while (auxiliary != 0) {
// Get the last digit
digit = auxiliary % 10;
sum = sum + Int(pow(Double(digit), Double(size)));
//Remove last digit
auxiliary /= 10;
//Reduce the length size
size -= 1;
}
if (sum == number) {
print(number ," Is Disarium Number");
} else {
print(number ," Is not Disarium Number");
}
}
}
func main() {
let obj: MyNumber = MyNumber();
// Test Case
obj.is_disarium(89);
obj.is_disarium(72);
obj.is_disarium(9);
}
main();```
```

#### Output

``````89  Is Disarium Number
72  Is not Disarium Number
9  Is Disarium Number``````
``````<?php
/*
Php Program
Check if a given number is disarium or not
*/
class MyNumber {
//Count the number of digits in number

public 	function digit_length(\$number) {
\$size = 0;
while (\$number != 0) {
\$number = intval(\$number / 10);
\$size++;
}
return \$size;
}
// Function to check whether a number is disarium or not

public 	function is_disarium(\$number) {
//set initial values
\$sum = 0;
//Find the length of given number
\$size = \$this->digit_length(\$number);
\$auxiliary = \$number;
while (\$auxiliary != 0) {
// Get the last digit
\$digit = \$auxiliary % 10;
\$sum = \$sum +pow(\$digit, \$size);
//Remove last digit
\$auxiliary= intval(\$auxiliary / 10);
//Reduce the length size
\$size--;
}
if (\$sum == \$number) {
echo(\$number ." Is Disarium Number\n");
} else {
echo(\$number ." Is not Disarium Number\n");
}
}
};

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

\$obj->is_disarium(89);
\$obj->is_disarium(72);
\$obj->is_disarium(9);
}
main();```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium Number``````
``````/*
Node Js Program
Check if a given number is disarium or not
*/
class MyNumber {
//Count the number of digits in number
digit_length(number) {
var size = 0;
while (number != 0) {
number = parseInt(number / 10);
size++;
}
return size;
}
// Function to check whether a number is disarium or not
is_disarium(number) {
//set initial values
var sum = 0;
//Find the length of given number
var size = this.digit_length(number);
var auxiliary = number;
while (auxiliary != 0) {
// Get the last digit
var digit = auxiliary % 10;
sum = sum + parseInt(Math.pow(digit, size));
//Remove last digit
auxiliary = parseInt(auxiliary / 10);
//Reduce the length size
size--;
}
if (sum == number) {
process.stdout.write(number + " Is Disarium Number\n");
} else {
process.stdout.write(number + " Is not Disarium Number\n");
}
}
}

function main(args) {
var obj = new MyNumber();
// Test Case
obj.is_disarium(89);
obj.is_disarium(72);
obj.is_disarium(9)
}
main();```
```

#### Output

``````89 Is Disarium Number
72 Is not Disarium Number
9 Is Disarium 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.