Skip to content

Commit bb68a89

Browse files
committed
first thought using recursive.Very slow
1 parent 4b313ce commit bb68a89

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

fibonacci/test.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// test data structure:sequence_list
2+
#include<stdio.h>
3+
#include<stdlib.h>
4+
5+
int fibonacci(int i) {
6+
if (i <= 0) {
7+
return 0;
8+
}
9+
if (i == 1 || i == 2) {
10+
return 1;
11+
}
12+
return fibonacci(i - 1) + fibonacci(i - 2);
13+
}
14+
15+
16+
int main() {
17+
printf("__________________");
18+
int num_100 = fibonacci(45);
19+
printf("%d\n", num_100);
20+
printf("__________________");
21+
system("pause");
22+
return 0;
23+
}

0 commit comments

Comments
 (0)