libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
Functions | |
template<class V > | |
constexpr V | gcd (const V x, const V y) noexcept(true) __attribute__((const)) |
Binary Greatest Common Divisor Algorithm. More... | |
|
inlineconstexprnoexcept |
Binary Greatest Common Divisor Algorithm.
This method is best suited to integers.
A one-liner for fun! (But it's slower, as it's got an extra jump...) for (u=x,v=y;v;r=uv,u=v,v=r);
Thanks to Knuth, et al for Euclid's Algorithm and the Binary GCD algorithm. See his book "Seminumerical Algorithms. Vol 2", pg 320.