Answer the question
In order to leave comments, you need to log in
Why StackOverFlowError?
class Factorial {
int factor(int n) {
if (n != 1)
return factor(n-1) * n;
else
return 1;
}
}
class Main {
public static void main(String[] args) {
Factorial f = new Factorial();
for (int i = 0; i < 1; i++) {
System.out.println(f.factor(i));
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question