Skip to content

Instantly share code, notes, and snippets.

@sameerg07
Created June 4, 2021 03:52
Show Gist options
  • Save sameerg07/e7aab97067942f81b84f8c63b7416a9d to your computer and use it in GitHub Desktop.
Save sameerg07/e7aab97067942f81b84f8c63b7416a9d to your computer and use it in GitHub Desktop.
Armstrong Number check in python
n=int(input())
# 153=1^3+5^3+3^3
def armstrong(n):
nums = [int(x)**3 for x in str(n)] ## separate the numbers and cube
if sum(nums) == n:
return True
else:
return False
print(armstrong(n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment