File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
/* *
2
2
* @file
3
- * @brief Naive recursive algorithm to calculate the n-th [Fibonacci
3
+ * @brief n-th [Fibonacci
4
4
* number](https://en.wikipedia.org/wiki/Fibonacci_sequence).
5
5
*
6
6
* @details
7
- * Calculate the the value on Fibonacci's sequence given an
8
- * integer as input.
7
+ * Naive recursive implementation to calculate the n-th Fibonacci number.
9
8
* \f[\text{fib}(n) = \text{fib}(n-1) + \text{fib}(n-2)\f]
10
9
*
11
10
* @see fibonacci_large.cpp, fibonacci_fast.cpp, string_fibonacci.cpp
@@ -26,16 +25,16 @@ namespace fibonacci {
26
25
/* *
27
26
* @brief Function to compute the n-th Fibonacci number
28
27
* @param n the index of the Fibonacci number
29
- * @returns n-th element of the Fbinacci 's sequence
28
+ * @returns n-th element of the Fibonacci 's sequence
30
29
*/
31
30
uint64_t fibonacci (uint64_t n) {
32
- // If the input is 0 or 1 just return the same
31
+ // If the input is 0 or 1 just return the same (Base Case)
33
32
// This will set the first 2 values of the sequence
34
33
if (n <= 1 ) {
35
34
return n;
36
35
}
37
36
38
- // Add the last 2 values of the sequence to get next
37
+ // Add the preceding 2 values of the sequence to get next
39
38
return fibonacci (n - 1 ) + fibonacci (n - 2 );
40
39
}
41
40
} // namespace fibonacci
You can’t perform that action at this time.
0 commit comments