25
Algorithms library
[algorithms]
25.9
Generalized numeric operations
[numeric.ops]
25.9.13
Greatest common divisor
[numeric.ops.gcd]
ðŸ”—
template
<
class
M,
class
N
>
constexpr
common_type_t
<
M,N
>
gcd
(
M m, N n
)
;
1
#
Requires:

m

and

n

shall be representable as a value of
common_type_t
<
M, N
>
.
[
â€‰
Note
:
These requirements ensure, for example, that
gcd
(
m,
m
)
=

m

is representable as a value of type
M
.
â€”
â€‰
end note
â€‰
]
2
#
Remarks:
If either
M
or
N
is not an integer type, or if either is
cv
bool
, the program is illformed
.
3
#
Returns:
Zero when
m
and
n
are both zero
.
Otherwise, returns the greatest common divisor of

m

and

n

.
4
#
Throws:
Nothing
.