solution link
whats wrong in it?
solution link
whats wrong in it?
hi @kumarankesh5feb
try this -->
#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;
}
ok…
expected o/p was–>
#1 : 2
#2 : 3
#3 : 5
ur o/p -->
2
3
5
so difference is clearly visible… ur logic was correct but o/p was not being printed in the format in which its expected…
corrected code -->
Hey is there anything else??