Cod sursa(job #1234184)

Utilizator js3292618Andrei Mihai js3292618 Data 26 septembrie 2014 21:23:54
Problema Algoritmul lui Euclid Scor 100
Compilator c Status done
Runda Arhiva educationala Marime 0.46 kb
#include <stdio.h>

static const char *fin = "euclid2.in", *fout = "euclid2.out";

static unsigned long cmmdc(unsigned long a, unsigned long b)
{
    if (a % b)
        return cmmdc(b, a % b);
    return b;
}

int main(void)
{
    unsigned n;
    unsigned long a, b;

    freopen(fin, "r", stdin);
    freopen(fout, "w", stdout);

    scanf("%u", &n);
    while (n--) {
        scanf("%lu %lu", &a, &b);
        printf("%lu\n", cmmdc(a, b));
    }

    return 0;
}