최대공약수 구하기

int gcd(int a, int b)
{
	int c;
	while (b != 0) { // 나눌 수가 0이 될때까지 반복
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}
반응형

+ Recent posts