Cod sursa(job #2551265)

Utilizator BlackMamba0019Dinu George BlackMamba0019 Data 19 februarie 2020 18:24:43
Problema Algoritmul lui Euclid Scor 0
Compilator c-64 Status done
Runda Arhiva educationala Marime 0.4 kb
#include <stdio.h>
#include <stdlib.h>
int gcd(int a, int b);
int main()
{
    int n, a, b;

    freopen("euclid2.in", "r", stdin);
    freopen("euclid2.out", "w", stdout);

    scanf("%d", &n);

    while(n>0)
    {
        scanf("%d %d", &a, &b);
        printf("%d\n", gcd(a,b));
    }


    return 0;
}

int gcd(int a, int b)
{
    if(!b) return a;
    return gcd(b, a%b);
}