i implemented this code using fibbonaci series and i am not able to figure out why its not working properly ,please help me to find mistake in my logic
Not working properly
#include
using namespace std;
int countstring(int n)
{
if(n<1)
return 0;
unsigned dp[100]={0};
//dp[0]=1;
dp[1]=2;
dp[2]=3;
for(int i=3;i<=n;i++)
{
dp[i]=dp[i-1]+dp[i-2];
}
return dp[n];
}
// Driver program to test above functions
int main()
{
int t,n;
cin>>t;
while(t–)
{
cin>>n;
cout << countstring(n) << endl;
}
return 0;
}
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.