aboutsummaryrefslogtreecommitdiffstats
path: root/Euclid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Euclid.cpp')
-rw-r--r--Euclid.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Euclid.cpp b/Euclid.cpp
new file mode 100644
index 0000000..b2daaaa
--- /dev/null
+++ b/Euclid.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+#include <cmath>
+
+using namespace std;
+
+int mgcd(int a, int b) {
+ if(a % b != 0) {
+ mgcd(b, a % b);
+ } else {
+ cout << "\nGreatest common divisor: " << b << endl;
+ }
+}
+
+int main() {
+ int x, y;
+ cout << "Enter 2 numbers: ";
+ cin >> x >> y;
+ mgcd(x, y);
+}