Source code for kyu_6.a_rule_of_divisibility_by_13.thirt

#  Created by Egor Kostan.
#  GitHub: https://github.com/ikostan
#  LinkedIn: https://www.linkedin.com/in/egor-kostan/


[docs]def thirt(n: int) -> int: """ The function which processes this sequence of operations on an integer n (>=0). `thirt` will return the stationary number. :param n: :return: """ REMAINDERS = (1, 10, 9, 12, 3, 4) while True: i = 0 temp = 0 t = str(n)[::-1] for s in t: temp += int(s) * REMAINDERS[i] if i + 1 < len(REMAINDERS): i += 1 else: i = 0 if int(n) == temp: return temp else: n = temp