ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::FibonacciCache Class Reference

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} \)

Detailed description

the numbers of Fibonacci, those computed kept between the calls

Member function documentation

◆ size()

int ADS::FibonacciCache::size ( void ) const
nodiscard

how many numbers are kept, \( F_0 , \ldots , F_{\mathrm{size}() - 1} \)

◆ value()

std::uint64_t ADS::FibonacciCache::value ( int n) const
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}} \]

Precondition
\( 0 \le n \le 92 \)
Postcondition
the numbers up to \( F_n \) are kept

The documentation for this class was generated from the following file: