#include <stdio.h>

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    int R = a % b;

    while (b != 0) {
        R = a % b; // 먼저 나머지를 구하고 시작해야 b에 할당할 값이 생기는듯
        // a에 b를 할당하는 것을 먼저 하면, 기존의 a를 잃게 되어 연산을 하고 할당해야 함
        a = b;
        b = R;
    }
    printf("%d", a);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: