You are viewing a single comment's thread from:
RE: AP Computer Science - The Armstrong Numbers
Hi, I took your great post as reason to implement this in python myself.
def getArmstongNumbers(start, end):
armstongNumbers = []
for nr in range(start, end):
sum = 0
for digit in str(nr):
sum += pow(int(digit), len(str(nr)))
if sum == nr:
armstongNumbers += [nr]
return armstongNumbers
print(getArmstongNumbers(1, 100000))
Maybe we will find more users who post their own implementation here.
The readability is lost, but it is even shorter.
Awesome work guys! Glad I could inspire you to try it out!