Class Assignment

Is their any other specific approach for this question or we are sipposed to do this question via fibonacci series approach?

hi @mvermav19
the way u have done using char array is also correct… for ease purpose u can do it like Fibonacci also…

#include <bits/stdc++.h>
using namespace std;

long long int fib(long long int n)
{
    if (n <= 1)
        return n;

    return fib(n - 1) + fib(n - 2);
}

int main()
{
    int testCases;
    cin >> testCases;
    int k = 1;

    while (testCases--)
    {
        int n;
        cin >> n;
        cout << "#" << k++ << " : " << fib(n+2) << endl;
    }

    return 0;
}

hey, is there anything else??

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

no sir that’ll be all. Thank you

1 Like