160. 輾轉相除法
user_6817964
c_cpp
3 years ago
277 B
5
Indexable
int GCD(int t, int v) {
if (t % v == 0) {
return v;
}
else {
GCD(v, t % v);
}
}
int main() {
int a, b;
scanf("%d", &a);
scanf("%d", &b);
int temp;
if (b > a) {
temp = a;
a = b;
b = temp;
}
printf("%d\n", GCD(a, b));
return 0;
}
Editor is loading...