更相减损术

https://baike.baidu.com/item/更相减损术/449183

c++ 代码

#include <iostream>

using namespace std;
int gcd(int a,int b){
    while(a != b) {
        if (a > b) a-=b;
        else b -= a;
    }
    return a;
}
int main(void) {
    int a,b;
    cin >> a >> b;
    cout << gcd(a,b) << endl;
    
    
}