set low to 1 and high to max ( a , b ) * n , here we have taken high as 10 ^ 18
var low = 1 , high = Number . MAX_VALUE , mid ; var lcm = parseInt ( ( a * b ) / gcd ( a , b ) ) ; while ( low < high ) { mid = low + parseInt ( ( high - low ) / 2 ) ;