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/benchmark/check_armstrong.py

19 lines
339 B
Python
Raw Permalink Normal View History

2023-11-13 12:47:53 +00:00
# Based on https://github.com/AllAlgorithms, python/algorithms/math/check_armstrong.py
def check_armstrong(n: int) -> bool:
assert n >= 0
if n == 0 or n == 1:
return True
if n <= 150:
return False
t = n
sum = 0
while t != 0:
r = t % 10
sum = sum + (r * r * r)
t = t // 10
if sum == n:
return True
else:
return False