View source code
Display the source code in std/numeric.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.numeric.gcd
Computes the greatest common divisor of
and a
by using
Euclid's algorithm.
b
Prototype
T gcd(T)( T a, T b );
Example
assert(gcd(2 * 5 * 7 * 7, 5 * 7 * 11) == 5 * 7); const int a = 5 * 13 * 23 * 23, b = 13 * 59; assert(gcd(a, b) == 13);
Authors
Andrei Alexandrescu, Don Clugston, Robert Jacques