I know this is a classic interview question, but here is my quick attempt at creating a function which returns the lowest common multiple of two numbers, something I never have to do in my day job:
def calc_common_multiplyer(int_low, int_high)
i = 1
int_high_res = []
while true
int_high_res << int_high * i
if int_high_res.include?(int_low * i)
return int_low * i
end
i = i+1
end
end
I feel that this is very clunky. Is there a more efficient or standard solution?
I’d do this in Ruby:
🙂