Write a Python Program to display weather a given number is an
Armstrong number or not.
Answers
Answered by
1
Answer:
n=int(input("Enter any number: ")) a=list(map(int,str(n))) b=list(map(lambda x:x**3,a)) if(sum(b)==n): print("The number is an armstrong number. ") else: print("The number isn't an arsmtrong number. ")
Answered by
2
Answer:
A number is called Armstrong number if it is equal to the sum of the cubes of its own digits.
For example: 153 is an Armstrong number since 153 = 1*1*1 + 5*5*5 + 3*3*3.
num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp // =10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
Similar questions
Business Studies,
5 months ago
English,
5 months ago
Math,
5 months ago
Computer Science,
11 months ago
English,
11 months ago
Physics,
1 year ago
Music,
1 year ago