For example 135 is a DISARIUM
(Workings 11+32+53 = 135, some other DISARIUM are 89, 175, 518 etc
(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
0 comments:
Post a Comment