carb::cpp::gcd

Defined in carb/cpp/Numeric.h

template<class M, class N>
inline constexpr std::common_type_t<M, N> carb::cpp::gcd(M m, N n) noexcept

Computes the greatest common divisor of two integers.

If either M or N is not an integer type, or if either is (possibly cv-qualified) bool, the program is ill- formed. If either |m| or |n| is not representable as a value of type std::common_type_t<M, N>, the behavior is undefined.

Parameters
  • m – Integer value

  • n – Integer value

Returns

If both m and n are 0, returns 0; otherwise returns the greatest common divisor of |m| and |n|.