0
How to perform a LCM ?
2 Answers
+ 1
http://code.sololearn.com/cioeKqsAyiGb
int gcd(int a, int b) {
while(true) {
if (a == 0) {
return b;
}
b %= a;
if (b == 0) {
return a;
}
a %= b;
}
}
int lcm(int a, int b) {
int gcdab;
gcdab = gcd(a, b);
if (gcdab != 0) {
return a/gcdab * b;
} else {
return 0;
}
}