We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 5122cae + c6ff92f commit 873919bCopy full SHA for 873919b
algorithms/maths/lcm.m
@@ -0,0 +1,11 @@
1
+% function to calculate lcm of two number a and b using gcd of two numbers.
2
+
3
+function [ret] = lcm(a, b)
4
+ if b == 0
5
+ re = a;
6
+ ret=(a*b)/re; % i.e zero
7
8
+ else
9
+ re = gcd(b, mod(a, b));
10
+ ret=(a*b)/re;
11
+ end
0 commit comments