I've created an android app that calculates the factorial of an input number. My code is:
void factorial(int x){
if(x>=0){
BigInteger res= new BigInteger("1");
for(int i=x; i>1; i--){
res = res.multiply(BigInteger.valueOf(i));
}
TextView text = (TextView)findViewById(R.id.resultTextView);
text.setText(res.toString());
}
}
It works but when I try calculating factorial 80.000 and more the app stucks for a moment and then exits, reloading the graphical 'desktop' inteface of android. The same piece of code run by a pc creates no problems. How can I fix my app to calculate those values rather than terminate itself?
Thank's in advance.