Я пытаюсь заполнить вопрос проекта Euler и пытаться сделать рекурсивное решение, но я получаю ошибку переполнения стека и не могу выяснить, почему. < /p>
Любая помощь будет отличной.public class Collatz {
public static void main(String[] args) {
List length = new ArrayList();
for(int i = 13; i < 1000000; i++){
length.add(collat(i, 0));
}
}
public static int collat(int x, int c){
if(x == 1){
return c;
}
if(x % 2 == 0){
return collat(x/2, c + 1);
}else{
return collat((3 * x) + 1, c + 1);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/207 ... flow-error