Answer to Question #284709 in C++ for papi

Question #284709

Write a C program that generate the number series below.

1 2 4 7 11 16 22 29 37 46


1
Expert's answer
2022-01-05T14:59:07-0500
#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;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog