mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 01:18:23 +08:00
find_lcm.js: Standardjs fixes (#146)
This commit is contained in:
@ -13,21 +13,21 @@
|
|||||||
|
|
||||||
// Find the LCM of two numbers.
|
// Find the LCM of two numbers.
|
||||||
function findLcm (num1, num2) {
|
function findLcm (num1, num2) {
|
||||||
var max_num
|
var maxNum
|
||||||
var lcm
|
var lcm
|
||||||
// Check to see whether num1 or num2 is larger.
|
// Check to see whether num1 or num2 is larger.
|
||||||
if (num1 > num2) {
|
if (num1 > num2) {
|
||||||
max_num = num1
|
maxNum = num1
|
||||||
} else {
|
} else {
|
||||||
max_num = num2
|
maxNum = num2
|
||||||
}
|
}
|
||||||
lcm = max_num
|
lcm = maxNum
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((lcm % num1 === 0) && (lcm % num2 === 0)) {
|
if ((lcm % num1 === 0) && (lcm % num2 === 0)) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
lcm += max_num
|
lcm += maxNum
|
||||||
}
|
}
|
||||||
return lcm
|
return lcm
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user