Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Armstrong Number Checking by Katarzyna_Golab
def is_armstrong(num: int) -> bool:
num_str = str(num)
num_digits = len(num_str)
armstrong_sum = sum(int(digit) ** num_digits for digit in num_str)
return armstrong_sum == 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!")
Jan. 22, 2024