Files
2025-10-25 03:02:53 +03:00

42 lines
1.2 KiB
Markdown

[numeric.ops.lcm]
# 26 Algorithms library [[algorithms]](./#algorithms)
## 26.10 Generalized numeric operations [[numeric.ops]](numeric.ops#lcm)
### 26.10.15 Least common multiple [numeric.ops.lcm]
[🔗](#lib:lcm)
`template<class M, class N>
constexpr common_type_t<M, N> lcm(M m, N n);
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13309)
*Mandates*: M and N both are integer types other thancv bool[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13314)
*Preconditions*: |m| and |n| are representable as a value of common_type_t<M, N>[.](#2.sentence-1)
The least common multiple of |m| and |n| is representable as a value of type common_type_t<M, N>[.](#2.sentence-2)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13321)
*Returns*: Zero when either m or n is zero[.](#3.sentence-1)
Otherwise, returns the least common multiple of |m| and |n|[.](#3.sentence-2)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L13326)
*Throws*: Nothing[.](#4.sentence-1)