Friends pairing problem

#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

ll dp[10005];
ll check(int n)
{
	if(n==0)
		return 0;
	if(dp[n]!=-1)
		return dp[n];
	dp[n]=((n-1)+((n-1)*check(n-1)));
	//cout<<dp[n]<<endl;
	return dp[n];
}
int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	cin>>T;
	// cin.ignore(); must be there when using getline(cin, s)
	while(T--)
	{
		ll n;
		cin>>n;
		for(int i=1;i<10005;i++)
		dp[i]=-1;
		cout<<check(n)<<endl;
		
	}
	return 0;
}

why my code giving is wrong ans

recurrence should be:

check(n-1) + (n-1)*check(n-2)

if the first person goes alone then the number of ways is given by check(n-1) and if the first person wants to take someone then number of ways is given by (n-1)*check(n-2).