From the statement we can understand that our answer is not greater than 106 and we have to find the smallest positive number which is divisible by A and B, So now we can start a loop from 1 to 106 and find our answer.
Time complexity: O()
Space complexity: O()