diff --git a/Maths/FindLcm.js b/Maths/FindLcm.js index 0d09a7affb..101da8565a 100644 --- a/Maths/FindLcm.js +++ b/Maths/FindLcm.js @@ -23,21 +23,14 @@ const findLcm = (num1, num2) => { return 'Please enter whole numbers.' } - let maxNum - let lcm - // Check to see whether num1 or num2 is larger. - if (num1 > num2) { - maxNum = num1 - } else { - maxNum = num2 - } - lcm = maxNum + // Get the larger number between the two + const maxNum = Math.max(num1, num2) + let lcm = maxNum while (true) { - if (lcm % num1 === 0 && lcm % num2 === 0) break + if (lcm % num1 === 0 && lcm % num2 === 0) return lcm lcm += maxNum } - return lcm } export { findLcm }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: