-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject.cpp
59 lines (47 loc) · 1017 Bytes
/
Project.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
using namespace std;
int fibonacciSequence (int i)
{
if (i <= 0)
{
return i; //A value to show that the program is not working.
}
if (i <= 2)
{
return 1;
}
else
{
int j = fibonacciSequence (i - 1);
int k = fibonacciSequence (i - 2);
return (j + k);
}
}
int main(void)
{
int i = 0;
int j = fibonacciSequence (i);
std::cout << j << std::endl;
i = 1;
j = fibonacciSequence (i);
std::cout << j << std::endl;
i = 2;
j = fibonacciSequence (i);
std::cout << j << std::endl;
i = 3;
j = fibonacciSequence (i);
std::cout << j << std::endl;
i = 5;
j = fibonacciSequence (i);
std::cout << j << std::endl;
i = 8;
j = fibonacciSequence (i);
std::cout << j << std::endl;
i = -1;
j = fibonacciSequence (i);
std::cout << j << std::endl;
i = 10;
j = fibonacciSequence (i);
std::cout << j << std::endl;
return 0;
};