Editor

Armstrong Number

Programs with input · Intermediate · about 8 min

An Armstrong number equals the sum of its digits, each raised to the power of how many digits the number has. For example, 153 has 3 digits, and 1**3 + 5**3 + 3**3 is 1 + 125 + 27, which is 153.

Read a whole number (1 or more) and print 153 is an Armstrong number or 154 is not an Armstrong number.

The prompts inside input() are not checked, only what you print.

Examples

You type:

153

The program prints:

153 is an Armstrong number

You type:

154

The program prints:

154 is not an Armstrong number
n = int(input("Number: "))
# Print whether n is an Armstrong number
The solution opens after your first Check.