Skip to content

Instantly share code, notes, and snippets.

@ayeshLK
Created January 4, 2022 20:36
Show Gist options
  • Save ayeshLK/1aa46586a0e3b62311beb3ce625c998c to your computer and use it in GitHub Desktop.
Save ayeshLK/1aa46586a0e3b62311beb3ce625c998c to your computer and use it in GitHub Desktop.
function leastCommonMultiple(int a, int b) returns int {
int counter = 1;
while true {
counter += 1;
// if the `counter` is divisible by `a` and `b` break the loop
if counter % a == 0 && counter % b == 0 {
break;
}
}
return counter;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment