-3

Can anyone help me, I have no idea how to find the lowest common multiple.

For example with the numbers 4 and 5 which is 20. This is what I want to achieve in code.

Thank you

Legend2525
  • 47
  • 1
  • 1
  • 4

1 Answers1

5

This isn't the best solution but it is a solution see the links in the replies for better solutions

b = 4;
a = 5;

for(int i = 1; i <= b; i++) {
    if(i*a % b == 0)
        return abs(i*a);
}

Thanks iamnotmaynard for the suggestion

Kevin
  • 750
  • 2
  • 10
  • 20