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/gcd.py

17 lines
406 B
Python
Raw Normal View History

2023-11-13 15:33:20 +00:00
def gcd(a: int, b: int) -> int:
assert ((a > 0) and (b > 0))
if (evaluate_condition(1, 'Eq', a, 1) or evaluate_condition(2, 'Eq', b, 1)):
return 1
if evaluate_condition(3, 'Eq', a, b):
return a
if evaluate_condition(4, 'Gt', b, a):
(a, b) = (b, a)
while evaluate_condition(5, 'NotEq', b, 0):
temp = b
b = (a % b)
a = temp
return a