diff --git a/math/fibonacci.cpp b/math/fibonacci.cpp index 1a5f4afb4..034b91970 100644 --- a/math/fibonacci.cpp +++ b/math/fibonacci.cpp @@ -5,6 +5,8 @@ * Calculate the the value on Fibonacci's sequence given an * integer as input. * \f[\text{fib}(n) = \text{fib}(n-1) + \text{fib}(n-2)\f] + * + * @see fibonacci_large.cpp */ #include #include @@ -15,7 +17,8 @@ int fibonacci(unsigned int n) { /* If the input is 0 or 1 just return the same This will set the first 2 values of the sequence */ - if (n <= 1) return n; + if (n <= 1) + return n; /* Add the last 2 values of the sequence to get next */ return fibonacci(n - 1) + fibonacci(n - 2); diff --git a/others/fibonacci_large.cpp b/others/fibonacci_large.cpp index 6f36702a2..6b556066a 100644 --- a/others/fibonacci_large.cpp +++ b/others/fibonacci_large.cpp @@ -1,11 +1,14 @@ /** - * Computes N^th Fibonacci number given as + * @file + * @brief Computes N^th Fibonacci number given as * input argument. Uses custom build arbitrary integers library * to perform additions and other operations. * * Took 0.608246 seconds to compute 50,000^th Fibonacci * number that contains 10450 digits! - **/ + * + * @see fibonacci.cpp + */ #include #include @@ -13,6 +16,10 @@ #include "./large_number.h" +/** Compute fibonacci numbers using the relation + * \f[f(n)=f(n-1)+f(n-2)\f] + * and returns the result as a large_number type. + */ large_number fib(uint64_t n) { large_number f0(1); large_number f1(1);