0

How to perform a LCM ?

12th Sep 2016, 4:53 PM
mukul joshi
2 Réponses
6th Nov 2017, 12:40 PM
#RahulVerma
#RahulVerma - avatar
+ 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; } }
12th Sep 2016, 7:33 PM
Zen
Zen - avatar