Click here to Skip to main content
11,929,249 members (53,279 online)
Click here to Skip to main content
Add your own
alternative version


1 bookmarked

Fast Greatest Common Divisor (GCD) Algorithm

, 18 Feb 2011 CPOL
Rate this:
Please Sign up or sign in to 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.


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
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

You may also be interested in...

Comments and Discussions

GeneralHi Mauro, You are absolutely right; that's exactly how it's... Pin
DrABELL18-Feb-11 9:48
memberDrABELL18-Feb-11 9:48 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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