Loading...
Loading...
Loading...
A number is an Armstrong number when the sum of its digits, each raised to the power of the digit count, equals the number. For example 153 = 1^3 + 5^3 + 3^3. Write is_armstrong(n) and print Armstrong or Not Armstrong.
Armstrong or Not Armstrong.Example 1
Input
153
Output
Armstrong
1 + 125 + 27 = 153.
Example 2
Input
154
Output
Not Armstrong
1 + 125 + 64 = 190, not 154.
Try the problem first. Open one hint at a time.
First count the digits, then add each digit raised to that count.
Count digits by dividing by 10 in a loop, using a copy so n stays available for the final comparison.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor