I get the error java.lang.StackOverflowError when I try to run my code:
public class calc {
public static void main(String[] args){
double zahl = 847362;
System.out.println( wannawoerk(zahl) );
}
public static double wannawoerk(double zahl){
if (zahl == 1)
return 1;
else
return wannawoerk(zahl - 1) + zahl;
} }
Is there any workaround for this problem? I have to use a recursive function without for, while, etc.