Get the latest tech news

Binary GCD


In this section, we will derive a variant of gcd that is ~2x faster than the one in the C++ standard library. #Euclid’s Algorithm Euclid’s algorithm solves the problem of finding the greatest common divisor (GCD) of two integer numbers $a$ and $b$, which is defined as the largest such number $g$ that divides both $a$ and $b$:$$ \gcd(a, b) = \max_{g: \; g|a \, \land \, g | b} g $$ You probably already know this algorithm from a CS textbook, but I will summarize it here.

None

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Binary GCD

Binary GCD

Photo of GCD

GCD