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.
1 parent 6f129b8 commit c6ff92fCopy full SHA for c6ff92f
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