Your logic is partially wrong.Basically you are just calculating the lcm of given numbers but user asks to find least k satisfying given condition.but yours is not least k. Try for case n=340 and m=230 actual ans is 1564 but your code gives 7820.
Note: lcm will not always be the least k satisfying given conditions in the problem.
Hint:prime factorize m,n and try to get the ans...try few more cases and you will get it.