Created
June 4, 2021 03:52
-
-
Save sameerg07/e7aab97067942f81b84f8c63b7416a9d to your computer and use it in GitHub Desktop.
Armstrong Number check in python
This file contains hidden or 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
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