This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
kse-02/instrumented/check_armstrong.py

20 lines
471 B
Python
Raw Normal View History

2023-11-13 15:33:20 +00:00
def check_armstrong(n: int) -> bool:
assert (n >= 0)
if (evaluate_condition(1, 'Eq', n, 0) or evaluate_condition(2, 'Eq', n, 1)):
return True
if evaluate_condition(3, 'LtE', n, 150):
return False
t = n
sum = 0
while evaluate_condition(4, 'NotEq', t, 0):
r = (t % 10)
sum = (sum + ((r * r) * r))
t = (t // 10)
if evaluate_condition(5, 'Eq', sum, n):
return True
else:
return False