Friends Pairing Problem

Here is my code :

Its showing wrong ans.

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

int pairFriends(int n) {
if(n == 0 || n == 1) {
return 1;
}
return pairFriends(n - 1) + (n - 1) * pairFriends(n-2);
}

int main()
{
int t; cin >> t;
while(t–) {
int n; cin >> n;
cout << pairFriends(n) << endl;
}
return 0;
}

Hi @deep_01,
Chane the return type of pairFriends from int to ll

ll pairFriends(int n) {

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.