65.9K
CodeProject is changing. Read more.
Home

Fast Greatest Common Divisor (GCD) Algorithm

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (1 vote)

Feb 18, 2011

CPOL
viewsIcon

8728

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.