Last active
August 29, 2015 14:07
-
-
Save julio73/224fbe7da37b52e16d63 to your computer and use it in GitHub Desktop.
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
""" | |
An Armstrong number is an n-digit number that is equal to the sum of the nth powers of its digits | |
""" | |
def isArmstrongNumber(x): | |
return sum([n**len(str(x)) for n in [int(d) for d in list(str(x))]]) == x | |
[x for x in range(100000) if isArmstrongNumber(x)] | |
#=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment