Find the previous Armstrong number
Problem to find the previous Armstrong number in given number.
If given number equal to the power of each and every digit with length of the given number and sum the powered value.That is called Armstrong number.Armstrong number full Explain
Example-1:
Input : n = 15 Output : 9
Example-2:
Input : n = 160 Output : 153
Solution
from itertools import count n = 15 for i in count(n,-1): s = str(i) sum = 0 for j in s: sum += int(j)**len(s) if sum == int(s): print(sum) break
Output
9