fun gcd(num1: Int, num2: Int): Int {
var a = num1
var b = num2
while (a != b) {
if (a > b) {
a -= b
} else {
b -= a
}
}
return a
}
fun main() {
val a = 32
val b = 12
val result = gcd(a, b)
println("GCD($a, $b) = $result")
}
ZnVuIGdjZChudW0xOiBJbnQsIG51bTI6IEludCk6IEludCB7CiAgdmFyIGEgPSBudW0xCiAgdmFyIGIgPSBudW0yCgogIHdoaWxlIChhICE9IGIpIHsKICAgIGlmIChhID4gYikgewogICAgICBhIC09IGIKICAgIH0gZWxzZSB7CiAgICAgIGIgLT0gYQogICAgfQogIH0KCiAgcmV0dXJuIGEKfQoKZnVuIG1haW4oKSB7CiAgdmFsIGEgPSAzMgogIHZhbCBiID0gMTIKCiAgdmFsIHJlc3VsdCA9IGdjZChhLCBiKQoKICBwcmludGxuKCJHQ0QoJGEsICRiKSA9ICRyZXN1bHQiKQp9