-
-
Save bilinin/52292654001b7eefee3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
long long gcd(long long a, long long b){ | |
long long r; | |
while (b != 0){ | |
r = a%b; a = b; b = r; | |
} | |
return a; | |
} | |
int Min(int a,int b){ | |
int min; | |
if(a<b) | |
min=a; | |
else | |
min=b; | |
return min; | |
}; | |
int gcd_(int a,int b){ | |
int rez=0; | |
for(int i=1;i<Min(a,b);i++){ | |
if((a%i==0)&&(b%i==0)){ | |
if(i>rez){ | |
rez=i; | |
} | |
} | |
} | |
return rez; | |
} | |
int main() { | |
long long result; | |
cout<<"lolled_1:="<<gcd(15,12)<<endl; | |
cout<<"lolled_2:="<<gcd_(15,12); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment