GCD and LCM.

This commit is contained in:
Anthony Calandra
2023-02-20 20:22:40 -05:00
parent 5a9e63549e
commit 2328e86239
2 changed files with 20 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ C++17 includes the following new library features:
- [std::clamp](#stdclamp)
- [std::reduce](#stdreduce)
- [prefix sum algorithms](#prefix-sum-algorithms)
- [gcd and lcm](#gcd-and-lcm)
C++14 includes the following new language features:
- [binary literals](#binary-literals)
@@ -1254,6 +1255,15 @@ std::transform_exclusive_scan(std::cbegin(a), std::cend(a),
std::ostream_iterator<int>{ std::cout, " " }, 0, std::plus<>{}, times_ten); // 0 10 30
```
### GCD and LCM
Greatest common divisor (GCD) and least common multiple (LCM).
```c++
const int p = 9;
const int q = 3;
std::gcd(p, q); // == 3
std::lcm(p, q); // == 9
```
## C++14 Language Features
### Binary literals