aboutsummaryrefslogtreecommitdiff
path: root/rcc-legacy/tests/upload/gcd_iterative.sy
blob: 3ed22dbdce7400aa6c8e4c65a995f33fd856f877 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int gcd(int a, int b){
    while(a != 0 && b != 0){
        if(a > b) a = a % b;
        else b = b % a;
    }
    if(a != 0) return a;
    else return b;
}

int main(){
    int a, b;
    int c;
    a = getint();
    b = getint();
    c = gcd(a, b);
    return c;
}