Getting SIGSEGV error

i am getting SIGSEGV error in this beginner level question https://www.codechef.com/problems/FCTRL2

Please tell me what to do next and how to solve this problem.
Here is my code…

#include
using namespace std;

int factorial(int n){

int fac=1;
while(n){

fac*=n;
n–;
}

return fac;
}

int main(){

int testcase,n,i=-1;
cin>>testcase;
int ans[5];
while(testcase){
i++;
cin>>n;
ans[i]=factorial(n);
–testcase;
}

for(int j=0;j<=i;j++)
cout<<endl<<ans[j];
return 0;

}