Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 629 Bytes

LCM.md

File metadata and controls

18 lines (11 loc) · 629 Bytes

Problem 4: LCM Calculation

Write a method to compute the Least Common Multiple (LCM) of two numbers using loops and conditionals.

Explanation

The Least Common Multiple of two numbers is the smallest positive integer that is divisible by both numbers. For example, the LCM of 4 and 5 is 20. This can be found by iterating through multiples of the larger number until a multiple of the smaller number is found.

Constraints

  • The method should not use any built-in functions for GCD or LCM.
  • The method should handle large values of the input numbers efficiently.

Example

lcm(4, 5); // returns 20