Answer:
#include <stdio.h>
int fib(int n) {
if (n <= 0) {
return 0;
}
if (n <= 2) {
return 1;
}
return fib(n-1) + fib(n-2);
}
int main(void) {
for(int nr=0; nr<=20; nr++)
printf("Fibonacci %d is %d\\", nr, fib(nr) );
return 0;
}
Step-by-step explanation:
The code is a literal translation of the definition using a recursive function.
The recursive function is not per se a very efficient one.