Skip to content

Instantly share code, notes, and snippets.

@sysuin
Created December 23, 2018 14:50
Show Gist options
  • Save sysuin/811d81e4636a491b60c54920f8e40a2f to your computer and use it in GitHub Desktop.
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
# 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