diff --git a/program.c b/program.c index 68540cb..6601e9f 100644 --- a/program.c +++ b/program.c @@ -5,7 +5,7 @@ long long int nsd(long long int,long long int); long long int nsd(long long int cislo1,long long int cislo2){ - while (cislo1 != cislo2){ + /*while (cislo1 != cislo2){ if (cislo1 > cislo2){ cislo1 -= cislo2; } else{ @@ -13,9 +13,13 @@ long long int nsd(long long int cislo1,long long int cislo2){ } } return cislo1; + */ + if (cislo1 == 0) + return cislo2; + return nsd(cislo2 % cislo1, cislo1); } int main() { - //freopen("vstup.txt","r",stdin); + freopen("vstup.txt","r",stdin); char* prvy_vstup = malloc(100* sizeof(char)); char* druhy_vstup = malloc(100* sizeof(char)); long long int prve_cislo;