A three digit number is said to be an “Armstrong number” if the sum of the third power of its individual digits is equal to the number itself.
Example: 371 is an Armstrong number as 371 = 33 + 73 + 13
407 is an Armstrong number as 407 = 43 + 03 + 73
Write a pseudo-code to check whether a given three digit number is an Armstrong number.
Answers
Answered by
6
Answer:
# Python program to check if the number provided by the user is an Armstrong number or not
# take input from the user
num = int(input("Enter a number: "))
# initialize sum
sum = 0
# find the sum of the cube of each digit
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
# display the result
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")Explanation:
Similar questions
Science,
5 months ago
Social Sciences,
5 months ago
Social Sciences,
5 months ago
Math,
10 months ago
Math,
10 months ago
Math,
1 year ago
History,
1 year ago
English,
1 year ago