Search

DISARIUM NUMBER IN PYHTON

by 10:55:00 0 comments
A number will be called DISARIUM if sum of its digits powered with their respective position is equal to the original number.
For example 135 is a DISARIUM
(Workings 11+32+53 = 135, some other DISARIUM are 89, 175, 518 etc

SOURCE CODE:


n=input()
k=n
i=0
l=[]
while n!=0:
    l.append(n%10)
    n=n/10
    i+=1
e=i
sum=0
for j in range(i):
    m=l[j]**e
    sum+=m
    e-=1
if k==sum:
    print "Disarium"
else:
    print "Not Disarium"
   


Input:

134

Output

Not Disarium


Input:

135

Output:

Disarium 





                                       

Anonymous

Developer

This is created by GAVASKAR .

0 comments:

Post a Comment