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.
Sample Input 1
371
Sample Output 1
True
n = input('Enter 3 digit number here: ')
n1 = int(n)
if n1 == int(n[0])**3 + int(n[1])**3 + int(n[2])**3:
print(True)
else:
print(False)
Enter 3 digit number here: 371
True
Comments
Leave a comment