mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
syntax correction
This commit is contained in:
parent
412d3ff1a2
commit
260ba8d3a4
@ -1,5 +1,5 @@
|
|||||||
#include <iostream>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
/* Calculate the the value on Fibonacci's sequence given an
|
/* Calculate the the value on Fibonacci's sequence given an
|
||||||
integer as input
|
integer as input
|
||||||
@ -7,14 +7,13 @@ Fibonacci = 0, 1, 1, 2, 3, 5,
|
|||||||
8, 13, 21, 34, 55,
|
8, 13, 21, 34, 55,
|
||||||
89, 144, ... */
|
89, 144, ... */
|
||||||
|
|
||||||
int fibonacci(uint n) {
|
int fibonacci(unsigned int n) {
|
||||||
/* If the input is 0 or 1 just return the same
|
/* If the input is 0 or 1 just return the same
|
||||||
This will set the first 2 values of the sequence */
|
This will set the first 2 values of the sequence */
|
||||||
if (n <= 1)
|
if (n <= 1) return n;
|
||||||
return n;
|
|
||||||
|
|
||||||
/* Add the last 2 values of the sequence to get next */
|
/* Add the last 2 values of the sequence to get next */
|
||||||
return fibonacci(n-1) + fibonacci(n-2);
|
return fibonacci(n - 1) + fibonacci(n - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user