Programming-Idioms

History of Idiom 74 > diff from v44 to v45

Edit summary for version 45 :
New C++ implementation by user [WHS]

Version 44

2020-11-23, 20:01:09

Version 45

2020-12-24, 16:23:40

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Variables
x,a,b
Variables
x,a,b
Imports
#include <numeric>
Code
auto x = std::gcd(a, b);
Comments bubble
C++17 or later

Converts a and b to their absolute values
Doc URL
https://en.cppreference.com/w/cpp/numeric/gcd