1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// @Title: 得到 0 的操作数 (Count Operations to Obtain Zero)
// @Author: 15816537946@163.com
// @Date: 2022-02-13 10:55:40
// @Runtime: 0 ms
// @Memory: 1.9 MB
func countOperations(num1 int, num2 int) int {
    var ans int
    for num1 != 0 && num2 != 0 {
        if num1 > num2 {
            num1 -= num2
        } else {
            num2 -= num1
        }
        ans++
    }
    
    return ans
}