# Python Program to Check a Number is a Disarium Number

Write a Python program to check a number is a disarium number or not using a while loop. If the sum of the digits of a given number raised to the power of its respective positions equals the actual number, it is a disarium number. For instance, 175 = 11 + 72 + 53 = 1 + 49 + 125 = 175.

In this Python program, we divide the number into individual digits and find the sum. Next, the if statement checks whether the sum equals an actual number. If True, it is a disarium number.

```Number = int(input("Enter the Number to Check Disarium Number = "))
length = len(str(Number))

Temp = Number
Sum = 0
rem = 0

while Temp > 0:
rem = Temp % 10
Sum = Sum + int(rem**length)
Temp = Temp // 10
length = length - 1

print("The Sum of the Digits = %d" %Sum)

if Sum == Number:
print("\n%d is a Disarium Number." %Number)
else:
print("%d is Not a Disarium Number." %Number)```

In this Python example, we used the digitsCount and digitsSum to check whether the number is a disarium number or not.

```import math

def digitsCount(Number):
length = 0
while Number != 0:
length = length + 1
Number = Number // 10
return length

def digitsSum(Number, length):
Sum = 0
rem = 0

while Number > 0:
rem = Number % 10
Sum = Sum + math.pow(rem, length)
Number = Number // 10
length = length - 1
return Sum

Number = int(input("Enter the Number to Check Disarium Number = "))
length = digitsCount(Number)
Sum = digitsSum(Number, length)

print("The Sum of the Digits     = %d" %Sum)

if Sum == Number:
print("%d is a Disarium Number." %Number)
else:
print("%d is Not a Disarium Number." %Number)```
``````Enter the Number to Check Disarium Number = 175
The Sum of the Digits     = 175
175 is a Disarium Number.

Enter the Number to Check Disarium Number = 24
The Sum of the Digits     = 18
24 is Not a Disarium Number.``````

Python program to check a number is a disarium number or not using recursion.

```import math

length = 0
Sum = 0

def digitsCount(Number):
global length
if Number > 0:
length = length + 1
digitsCount(Number // 10)
return length

def digitsSum(Number, length):
global Sum
if Number > 0:
rem = Number % 10
Sum = Sum + math.pow(rem, length)
digitsSum(Number // 10, length = length - 1)
return Sum

Number = int(input("Enter the Number to Check Disarium Number = "))
length = digitsCount(Number)
Sum = digitsSum(Number, length)

print("The Sum of the Digits     = %d" %Sum)

if Sum == Number:
print("\n%d is a Disarium Number." %Number)
else:
print("%d is Not a Disarium Number." %Number)```
``````Enter the Number to Check Disarium Number = 98
The Sum of the Digits     = 73
98 is Not a Disarium Number.

Enter the Number to Check Disarium Number = 135
The Sum of the Digits     = 135

135 is a Disarium Number.``````