Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Third - w/o string solution in Clear category for Armstrong Number Checking by freeman_lex
def is_armstrong(num: int) -> bool:
temp, digits, count = num, [], 0
while temp:
temp, digit = divmod(temp, 10)
digits.append(digit)
count += 1
return sum(d**count for d in digits) == num
print("Example:")
print(is_armstrong(11))
# These "asserts" are used for self-checking
assert is_armstrong(153) == True
assert is_armstrong(370) == True
assert is_armstrong(947) == False
assert is_armstrong(371) == True
assert is_armstrong(407) == True
assert is_armstrong(163) == False
assert is_armstrong(100) == False
assert is_armstrong(8208) == True
assert is_armstrong(930) == False
assert is_armstrong(4) == True
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 24, 2023