Created
April 5, 2016 15:29
-
-
Save alonzoibarra97/e1e9c92517741294d582fafffea27862 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; | |
int gd_c (int a, int b){ | |
int gdc, mod1,div1; | |
do{ | |
if(a==0) | |
{ | |
gdc= b; | |
} | |
else{ | |
if(b==0) | |
{ | |
gdc= a; | |
} | |
else{ | |
do{ | |
mod1= a%b; | |
div1= a/b; | |
a= (b*div1)+mod1; | |
a=b; b=mod1; | |
}while(a==0||b==0) | |
} | |
} | |
}while(a==0||b==0); | |
return gdc; | |
} | |
int main () { | |
int num1,num2,rgdc; | |
cout<<"Give me the first number\n"; | |
cin>> num1; | |
cout<<"Give me the second number\n"; | |
cin>> num2; | |
rgdc= gd_c(num1,num2); | |
cout<< "The greatest common denominator of these numbers is: "<< rgdc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment