def gcd(a, b): while b > 0: a, b = b, a % b return a def gcd(a, b) a, b = b, a if a > b until a == 0 a, b = b % a, a end return b end private static long getKoyakusu(long a, long b) { long candidate = a; while (b % a != 0) { candidate = b % a; b = a; a = candidate; } return candidate; } Java Ruby Python