Skip to content

Instantly share code, notes, and snippets.

@aneury1
Created November 10, 2017 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aneury1/f9a6a341ba19bbc86014c2186f2ca7f8 to your computer and use it in GitHub Desktop.
Save aneury1/f9a6a341ba19bbc86014c2186f2ca7f8 to your computer and use it in GitHub Desktop.
#define MAX(X,Y) (X>Y)?X:Y
#define MIN(X,Y) (X<Y)?X:Y
int mcd(int x, int y)
{
int ret= -1;
int cociente =0;
int divisor = MAX(x,y);
int dividendo = MIN(x,y);
int resto =0;
do{
cociente = divisor / dividendo;
resto = divisor % dividendo;
if(resto == 0)
{
return dividendo;
}
divisor = dividendo;
dividendo = resto;
}while(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment