Created
December 23, 2018 14:50
-
-
Save sysuin/811d81e4636a491b60c54920f8e40a2f to your computer and use it in GitHub Desktop.
For a given 3 digit number, find whether it is armstrong number or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://practice.geeksforgeeks.org/problems/armstrong-numbers/0/?track=interview-mathematical | |
import os | |
import random | |
import re | |
import sys | |
t = int(input()) | |
for i in range(t): | |
n = int(input()) | |
temp = n | |
sum = 0 | |
while(temp>0): | |
digit = int(temp%10) | |
#print("digit is: ",digit) | |
sum+=(digit*digit*digit) | |
#print("sum is: ",sum) | |
temp = int(temp/10) | |
#print("temp is: ",temp) | |
#print(sum) | |
if sum == n: | |
print("Yes") | |
else: | |
print("No") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment