Skip to content

Instantly share code, notes, and snippets.

@bilinin
Created October 27, 2015 11:46
Show Gist options
  • Save bilinin/52292654001b7eefee3f to your computer and use it in GitHub Desktop.
Save bilinin/52292654001b7eefee3f to your computer and use it in GitHub Desktop.
#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