General Utility Library for C++14
2.11

Greatest common divisor and least common multiple.
Functions  
template<typename IntTypeA , typename IntTypeB >  
constexpr auto  gul14::gcd (IntTypeA a, IntTypeB b) 
Calculate the greatest common divisor of two integers using the Euclidean algorithm. More...  
template<typename IntTypeA , typename IntTypeB >  
constexpr auto  gul14::lcm (IntTypeA a, IntTypeB b) 
Calculate the least common multiple of two integers. More...  

inlineconstexpr 
Calculate the greatest common divisor of two integers using the Euclidean algorithm.
If both numbers are zero, the function returns zero. Otherwise, the result is a positive integer.
std::common_type_t<IntTypeA, IntTypeB>
) that both inputs can implicitly be converted to. If either a, b, or the result can not be represented by that type, the result is undefined.std::gcd()
from C++17, the GUL14 version cannot be used with integers of different signedness. This avoids undefined behavior when mixing unsigned integers with negative signed values: References gul14::abs().
Referenced by gul14::lcm().

inlineconstexpr 
Calculate the least common multiple of two integers.
If both numbers are zero, the function returns zero. Otherwise, the result is a positive integer.
std::common_type_t<IntTypeA, IntTypeB>
) that both inputs can implicitly be converted to. If either a, b, or the result can not be represented by that type, the result is undefined.std::lcm()
from C++17, the GUL14 version cannot be used with integers of different signedness. This avoids undefined behavior when mixing unsigned integers with negative signed values: References gul14::abs(), and gul14::gcd().