Leetcode Note: Go - Count Operations to Obtain Zero
Count Operations to Obtain Zero - LeetCode
https://leetcode.com/problems/count-operations-to-obtain-zero/
- Go 言語で取り組んだメモ
回答
[Go] bigger % smaller - Count Operations to Obtain Zero - LeetCode
https://leetcode.com/problems/count-operations-to-obtain-zero/solutions/1768076/go-bigger-smaller/
func countOperations(num1 int, num2 int) int {
var ops int
for num1 > 0 && num2 > 0 {
if num2 > num1 {
num1, num2 = num2, num1
}
ops += num1/num2
num1 %= num2
}
return ops
}