Click here to Skip to main content
Click here to Skip to main content

Fast Greatest Common Divisor (GCD) Algorithm

By , 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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mauro Leggieri
Web Developer
Argentina Argentina
Member
My name is Mauro Leggieri. I am 30 year-old, married and have a child.
 
I am a system engineer (UTN university) and am being programming for more than 20 years from the C64 to the PC and some microcontrollers.
 
Mostly of my time, I program games for Windows.
 
Soon, my site http://www.mauroleggieri.com.ar

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralHi Mauro, You are absolutely right; that's exactly how it's...memberDrABELL18 Feb '11 - 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 18 Feb 2011
Article Copyright 2011 by Mauro Leggieri
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid