Ok, this must be something really stupid....my statement is returning 2:
- When I print out the values they are all correct
- The return statement is wrong somehow
Code:
public static void main (String [] args)
{
System.out.println(countToTen(1));
}
public static int countToTen(int last_answer){
last_answer++;
if(last_answer != 10){
countToTen(last_answer);
}
return last_answer;
}
countToTenwhen you call it recursively...