tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
gcd.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2#ifndef TETL_NUMERIC_GCD_HPP
3#define TETL_NUMERIC_GCD_HPP
4
6
7namespace etl {
8
15template <typename M, typename N>
16[[nodiscard]] constexpr auto gcd(M m, N n) noexcept -> etl::common_type_t<M, N>
17{
18 if (n == 0) {
19 return m;
20 }
21 return gcd<M, N>(n, m % n);
22}
23
24} // namespace etl
25
26#endif // TETL_NUMERIC_GCD_HPP
constexpr auto gcd(M m, N n) noexcept -> etl::common_type_t< M, N >
Computes the greatest common divisor of the integers m and n.
Definition gcd.hpp:16
Definition adjacent_find.hpp:8
typename common_type< T... >::type common_type_t
Definition common_type.hpp:50