summaryrefslogtreecommitdiff
path: root/math/gcd-lcm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/gcd-lcm.cpp')
-rw-r--r--math/gcd-lcm.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/math/gcd-lcm.cpp b/math/gcd-lcm.cpp
new file mode 100644
index 0000000..3a0f742
--- /dev/null
+++ b/math/gcd-lcm.cpp
@@ -0,0 +1,7 @@
+ll gcd(ll a, ll b) {
+ return b == 0 ? a : gcd (b, a % b);
+}
+
+ll lcm(ll a, ll b) {
+ return a * (b / gcd(a, b)); //Klammern gegen Overflow
+} \ No newline at end of file