def CheckArmStrongNumber(n):
Flag=-1
s = str(n)
l = len(str(n))
Sum =0
for r in range(0,l):
a = int(s[r])
Sum = Sum + pow(a,l)
if(Sum == n): Flag=1
return(Flag)
u = int(input("Enter lower range: "))
v = int(input("Enter upper range: "))
f=-1
s=""
for r in range(u,v+1):
Flag = CheckArmStrongNumber(r)
if(Flag==1):
f=1
s = s + str(r) + " "
if(f==-1):
print("-1")
else:
print(s)
Comments
Leave a comment