Friends pairing problem , not able to get what is wrong in code

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

int f(int n,ll dp[])
{
if(n==0||n==1)
{
return 1;
}
if((dp[n])!=0)
{
return dp[n];
}
ll a=f(n-1,dp);
ll b=0;
if(n-1>0)
{
b=(n-1)*f(n-2,dp);
}
return dp[n]=(a+b);
}
int main()
{
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
ll dp[n+1]={0};
ll a= f(n,dp);
cout<<a<<endl;
}
return 0;
}

@goyal431
See your result for f(2,dp)
It should be 2
For your code it will be 1
if(n-1>0)
Make this >=