INFO505 Programmation C
Loading...
Searching...
No Matches
fibo.c
1#include <stdio.h>
2
3int fibo(int n) {
4 if(n <= 1) {
5 return 1;
6 }
7 int f1 = fibo(n-1);
8 int f2 = fibo(n-2);
9 int res = f1 + f2;
10 return res;
11}
12
13int main() {
14 for(int i = 0; i < 10; i++) {
15 printf("fibo %i : %i\n", i, fibo(i));
16 }
17 return 0;
18}