#include
using namespace std;
int count(int n)
{
if(n<=2)
{
return n;
}
return count(n-1)+n-1*count(n-2);
}
int main() {
int t;
cin>>t;
while(t–)
{
int x=0;
int n;
cin>>n;
x=count(n);
cout<<x<<endl;
}
return 0;
}
#include
using namespace std;
int count(int n)
{
if(n<=2)
{
return n;
}
return count(n-1)+n-1*count(n-2);
}
int main() {
int t;
cin>>t;
while(t–)
{
int x=0;
int n;
cin>>n;
x=count(n);
cout<<x<<endl;
}
return 0;
}
@mayank10 I don’t think there is something wrong in the logic but it may give wrong answer depending upon the values of n, so prefer to use long long int before submitting.