12,300,841 members (62,896 online)
Articles » Languages » C# » General » Alternatives
Alternatives
alternative version

12.2K views
2 bookmarked
Posted

# Fast Greatest Common Divisor (GCD) Algorithm

, 15 Feb 2011 CPOL
The computational efficiency of the Euclid's algorithm is much higher that the alternatives

## Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

11 Feb 2011
Can we simplify it by: (This essentially passes only two numbers). public int GCD(int value1, int value2){ int max = 0; bool gcdFound = false; int counter = 1; //Make sure both numbers are atleast 2 or above if (( value1 <= 1 ) || (value2 <= 1)) return...
14 Feb 2011
/// /// Find the Greatest Common Divisor /// /// Number a /// Number b /// The greatest common Divisor public static long GCD(long a, long b) ...
18 Feb 2011
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.