Programming Examples
Implement Python Script to check given number is Armstrong or not.
Implement Python Script to check given number is Armstrong or not.
Solutionnum = int(input("Enter a number: "))
temp = num
sum = 0
digits = len(str(num))
while temp > 0:
digit = temp % 10
sum += digit ** digits
temp //= 10
if sum == num:
print(num, "is an Armstrong number.")
else:
print(num, "is not an Armstrong number.")
▶ RUN Output/ Explanation: Enter a number: 153
153 is an Armstrong number.