Created
November 10, 2017 21:12
-
-
Save aneury1/f9a6a341ba19bbc86014c2186f2ca7f8 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
#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