We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Learn more about funding links in repositories.
Report abuse
There was an error while loading. Please reload this page.
1 parent 4098932 commit 8fc5390Copy full SHA for 8fc5390
Maths/FindLcm.js
@@ -23,21 +23,14 @@ const findLcm = (num1, num2) => {
23
return 'Please enter whole numbers.'
24
}
25
26
- let maxNum
27
- let lcm
28
- // Check to see whether num1 or num2 is larger.
29
- if (num1 > num2) {
30
- maxNum = num1
31
- } else {
32
- maxNum = num2
33
- }
34
- lcm = maxNum
+ // Get the larger number between the two
+ const maxNum = Math.max(num1, num2)
+ let lcm = maxNum
35
36
while (true) {
37
- if (lcm % num1 === 0 && lcm % num2 === 0) break
+ if (lcm % num1 === 0 && lcm % num2 === 0) return lcm
38
lcm += maxNum
39
40
- return lcm
41
42
43
export { findLcm }
0 commit comments