Moon Light Box

Time is Money

C - Get the Greatest Common Divisor

| Comments

#include<stdio.h>
#include<stdlib.h>

int main()
{
    int a, b, temp;

    while(scanf("%d %d", &a, &b) == 2)
    {
        while(a%b)
        {
            temp = a;
            a = b;
            b = temp % b;
        }

        printf("%d\n",b);
    }
    system("PAUSE");
    return 0;
}

C GCD

Comments

comments powered by Disqus