160. 輾轉相除法

 avatar
user_6817964
c_cpp
a year ago
277 B
1
Indexable
Never
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;
}