computes and caches Catalan numbers
More...
computes and caches Catalan numbers
for assert for std::uint64_t for std::size_t for std::transform_reduce for std::vector
◆ add()
| void catalan_numbers::add |
( |
| ) |
|
|
inlineprivate |
31{ known.push_back(this->compute_next()); }
◆ compute_next()
25 {
26 return std::transform_reduce(known.begin(), known.end(), known.rbegin(),
29 }
◆ get()
computes the n-th Catalan number and updates the cache.
- Returns
- the n-th Catalan number
38 {
39 while (known.size() <= n) {
40 this->add();
41 }
42 return known[n];
43 }
◆ known
The documentation for this class was generated from the following file: