Write a C program that generate the number series below.
1 2 4 7 11 16 22 29 37 46
#include<bits/stdc++.h>
using namespace std;
int fib(int n)
{
if (n <= 1)
return n;
return fib(n-1) + fib(n-2);
}
int main ()
{
int n = 9;
cout << fib(n);
return 0;
}
Comments
Leave a comment