Armstrong Numbers
- def armstrong(x,y):
- temp=0
- for i in range(x,y+1):
- sum=0
- temp=i
- while temp>0:
- r = temp % 10
- sum=sum+r*r*r
- temp=temp//10
- if(sum==i):
- print(sum)
- a=armstrong(int(input("Enter lower limit :")),int(input("Enter upper limit :"))
Output:
Enter lower limit :100 Enter upper limit :1000
153
370
371
407
153
370
371
407
No comments: