Advertisements
Advertisements
प्रश्न
Write a program to input any number and check whether given number is Armstrong or not.
कोड लेखन
Advertisements
उत्तर
For a three-digit Armstrong number, add the cubes of its digits and compare the sum with the original number.
n = int(input("Enter any number: "))
original = n
sum_of_cubes = 0
while n > 0:
digit = n % 10
sum_of_cubes += digit ** 3
n //= 10
if sum_of_cubes == original:
print("Armstrong number")
else:
print("Not an Armstrong number")
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
