Marbles problem

#include
#include<bits/stdc++.h>
using namespace std;
int fact(int x){
if (x==1||x==0){
return 1;
}else{
int ans=x*fact(x-1);
return ans;
}
}
int main() {
int n,k,s;
cin>>n>>k;
s=fact(n-1)/(fact(n+k)*fact(k-1));
cou<<s;
}

this is my code

/bin/run.sh: line 4: 18 Arithmetic exception (core dumped) ./exe

and above is the error please help me to resolve this error

It’s probably due to integer overflow, you need to use implementation of big integer class to pass the tests anyway,

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.