Skip to content

Commit ed5dc3a

Browse files
authored
Create FibonacciRecursive.cpp
1 parent 513070d commit ed5dc3a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/cpp/FibonacciRecursive.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
#include <iostream>
3+
4+
using namespace std;
5+
6+
int fibonacciRecursive(int n)
7+
{
8+
if (n == 0)
9+
{
10+
return 0;
11+
}
12+
else if (n == 1)
13+
{
14+
return 1;
15+
}
16+
else
17+
{
18+
return fibonacciRecursive(n-1) + fibonacciRecursive(n-2);
19+
}
20+
}
21+
22+
int main()
23+
{
24+
cout << fibonacciRecursive(12) << endl;
25+
}

0 commit comments

Comments
 (0)