Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 873919b

Browse files
authored
Merge pull request #71 from KaushalDevrari/patch-6
Create lcm.m
2 parents 5122cae + c6ff92f commit 873919b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎algorithms/maths/lcm.m‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /