In this article we will write a program in Python to find if a given number is Disarium Number.I hope you you have pyhon installed in your machine to write this program. If it’s not installed, then you can follow below link for installation.

http://vidyabhandar.com/how-to-install-python-in-windows/

Before writing the program, we need to know What is a Disarium Number. By seeing/listening the word Disarium you might be thinking what is a Disarium Number. So let’s understand the Disarium Number.

Disarium Number : A number is called Disarium if the sum of its digits powered with their respective positions is equal to the number itself.

Is this definition is not easy to understand? Let’s take a Example so that it will be easy to understand. In range 1 to 200 there are 12 Disarium Number 1, 2, 3, 4, 5, 6, 7, 8, 9, 89, 135, 175. So let’s take example of 89 & 135 as below.

Example 1Example 2Example 3
Number: 89
81+ 92 = 8+ 81 = 89
You can see 81+ 92 = 89 .
So 89 is a Disarium Number.
Number: 135
11+ 32+ 53 = 1+ 9 +125 = 135
You can see 11+ 32+ 53  = 135 .
So 135 is a Disarium Number.
Number: 175
11+ 72+ 53 = 1+ 49 +125 = 175
You can see 11+ 72+ 53 = 175 .
So 175 is a Disarium Number.

I think you understood the Disarium number . So let’s write the program.

#program to find if a given number is Disarium.
number = int(input("Enter a number "))
rem = s = 0;    
len = len(str(number))
     
x = number;    
     
#The sum of digits powered with their respective position    
while(number > 0):    
    rem = number%10;    
    s += int(rem**len);    
    number = number//10;    
    len -= 1;    
     
#to check if the sum is equal to the number
if(s == x):    
    print("Disarium number");    
else:    
    print("Not a Disarium number");    

Output:

Please write your valuable comments in the comment section if you find anything incorrect, or you want to share more information about this article..