Fast Greatest Common Divisor (GCD) Algorithm





4.00/5 (1 vote)
It is better to do this:public static long LCM(long a, long b){ return (a / GCD(a,b)) * b;}To avoid overflow on big numbers.
It is better to do this:
public static long LCM(long a, long b) { return (a / GCD(a,b)) * b; }To avoid overflow on big numbers.