Python Program to check if a number is Disarium number




What is the Disarium number?

A number is supposed to be the Disarium number when the aggregate of its digit raised to the intensity of their separate positions gets equivalent to the number itself.

1^1+ 7^2 + 5^3 = 1+ 49 + 125 = 175

Python Program to check if a number is Disarium number

num = int(input())
rem = s = 0;    
len = len(str(num))
     
#Makes a copy of the original number num    
n = num;    
     
#Calculates the sum of digits powered with their respective position    
while(num > 0):    
    rem = num%10;    
    s += int(rem**len);    
    num = num//10;    
    len -= 1;    
     
#Checks whether the sum is equal to the number itself    
if(s == n):    
    print( "disarium number");    
else:    
    print(" not a disarium number");    

Check Output Here