Created
March 21, 2019 19:51
-
-
Save s-melnikov/571e2a3fd580c431b859e2003c11f1cd to your computer and use it in GitHub Desktop.
Greatest common divider
This file contains hidden or 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 gcd(int a, int b) { | |
| while (a != b) { | |
| if (a > b) { | |
| a = a - b; | |
| } else { | |
| b = b - a; | |
| } | |
| } | |
| return a; | |
| } | |
| int main() { | |
| int a, b; | |
| cout << "a = "; | |
| cin >> a; | |
| cout << "b = "; | |
| cin >> b; | |
| cout << "GCD ( " << a << ", " << b << " ) = " << gcd(a, b) << endl; | |
| system("pause >> void"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment