|
ADS
Algorithms and Data Structures
|
the numbers of Fibonacci, those computed kept between the calls More...
#include <ADS/numeric/Combinatorics.h>
Public member functions | |
| std::uint64_t | value (int n) const |
| the number \( F_n \), the ones not kept yet computed from the last two kept | |
| int | size (void) const |
| how many numbers are kept, \( F_0 , \ldots , F_{\mathrm{size}() - 1} \) | |
the numbers of Fibonacci, those computed kept between the calls
|
nodiscard |
how many numbers are kept, \( F_0 , \ldots , F_{\mathrm{size}() - 1} \)
|
nodiscard |
the number \( F_n \), the ones not kept yet computed from the last two kept
In pseudocode, \( F \) the vector kept, \( ( 1 , 1 ) \) at first:
\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{value}( n ) \cr 2 & \quad \textbf{while}\ |F| \le n\ \textbf{do}\ \text{append } F[ |F| - 1 ] + F[ |F| - 2 ] \text{ to } F \cr 3 & \quad \textbf{return}\ F[ n ] \end{array}} \]