![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
n-th Fibonacci number. More...
#include <cstdint>#include <cassert>#include <iostream>Go to the source code of this file.
Namespaces | |
| namespace | math |
| for assert | |
| namespace | fibonacci |
| Functions for Fibonacci sequence. | |
Functions | |
| uint64_t | math::fibonacci::fibonacci (uint64_t n) |
| Function to compute the n-th Fibonacci number. | |
| static void | test () |
| Self-test implementation. | |
| int | main () |
| Main function. | |
n-th Fibonacci number.
Naive recursive implementation to calculate the n-th Fibonacci number.
\[\text{fib}(n) = \text{fib}(n-1) + \text{fib}(n-2)\]
Definition in file fibonacci.cpp.
| uint64_t math::fibonacci::fibonacci | ( | uint64_t | n | ) |
Function to compute the n-th Fibonacci number.
| n | the index of the Fibonacci number |
Definition at line 32 of file fibonacci.cpp.
| int main | ( | void | ) |
|
static |
Self-test implementation.
Definition at line 49 of file fibonacci.cpp.