This documentation is automatically generated by online-judge-tools/verification-helper
#include "algorithm/Math/NumberTheory/greatest_common_divisor.hpp"
2つの整数 $a, b$ の最大公約数 (GCD: Greatest Common Divisor) を求める.
本実装では「ユークリッドの互除法」を用いており,計算量は $\mathcal{O}(\log(\min(a,b)))$ となる.
#ifndef ALGORITHM_GREATEST_COMMON_DIVISOR_HPP
#define ALGORITHM_GREATEST_COMMON_DIVISOR_HPP 1
/**
* @brief Greatest Common Divisor(最大公約数)
* @docs docs/Math/NumberTheory/greatest_common_divisor.md
*/
namespace algorithm {
template <typename Type>
constexpr Type igcd(Type a, Type b) { return (b == 0 ? a : igcd(b, a % b)); }
} // namespace algorithm
#endif
#line 1 "algorithm/Math/NumberTheory/greatest_common_divisor.hpp"
/**
* @brief Greatest Common Divisor(最大公約数)
* @docs docs/Math/NumberTheory/greatest_common_divisor.md
*/
namespace algorithm {
template <typename Type>
constexpr Type igcd(Type a, Type b) { return (b == 0 ? a : igcd(b, a % b)); }
} // namespace algorithm