Movatterモバイル変換


[0]ホーム

URL:


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

Commitf7431a3

Browse files
author
kalvium
committed
function added
1 parent1d252d7 commitf7431a3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎Maths/lcm.cjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
functiongcd(a,b){
2+
while(b!==0){
3+
;[a,b]=[b,a%b]
4+
}
5+
returna
6+
}
7+
8+
functionlcm(a,b){
9+
if(a===0||b===0)return0
10+
returnMath.abs(a*b)/gcd(a,b)
11+
}
12+
13+
module.exports=lcm
14+
15+
console.log(lcm(12,18))// Output: 36
16+
console.log(lcm(5,0))// Output: 0
17+
console.log(lcm(7,3))// Output: 21

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp