3-digit Armstrong Number
Write a program to check if a given 3-digit number
The first line is an integer
The output should be a single line containing
In the given example
X = 371, The number of digits in 371 is 3. So, 33 + 73 + 13 = 371. Hence,
371 is an Armstrong number.So, the output should be
True
x = input()
length = len(x)
sum = 0
for i in x:
sum += int(i) ** length
if sum == int(x):
print(True)
exit()
print(False)
Comments
Leave a comment