Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise16.cpp
diff options
context:
space:
mode:
1 files changed, 19 insertions, 0 deletions
-rw-r--r--Week13/Exercise16.cpp19
diff --git a/Week13/Exercise16.cpp b/Week13/Exercise16.cpp
new file mode 100644
index 0000000..66f8e11
--- /dev/null
+++ b/Week13/Exercise16.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+
+unsigned gcd(unsigned a, unsigned b) {
+ if (a == b)
+ return a;
+ else if (a < b)
+ return gcd(b, a);
+ else
+ return gcd(a - b, b);
+}
+
+int main() {
+ unsigned a, b;
+ std::cin >> a >> b;
+
+ std::cout << gcd(a, b) << std::endl;
+
+ return 0;
+}