27
Algorithms library
[algorithms]
27.10
Generalized numeric operations
[numeric.ops]
27.10.14
Greatest common divisor
[numeric.ops.gcd]
🔗
template
<
class
M,
class
N
>
constexpr
common_type_t
<
M, N
>
gcd
(
M m, N n
)
;
1
#
Mandates
:
M
and
N
both are integer types other than
cv
bool
.
2
#
Preconditions
:
|
m
|
and
|
n
|
are representable as a value of
common_
type_
t
<
M, N
>
.
[
Note
1
:
These requirements ensure, for example, that
gcd
(
m,
m
)
=
|
m
|
is representable as a value of type
M
.
—
end note
]
3
#
Returns
: Zero when
m
and
n
are both zero
.
Otherwise, returns the greatest common divisor of
|
m
|
and
|
n
|
.
4
#
Throws
: Nothing
.