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
5
#include <
etl/_type_traits/common_type.hpp
>
6
7
namespace
etl
{
8
15
template
<
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
common_type.hpp
etl::gcd
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
etl
Definition
adjacent_find.hpp:8
etl::common_type_t
typename common_type< T... >::type common_type_t
Definition
common_type.hpp:50
include
etl
_numeric
gcd.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0