This is the following code I had for a recursion question
Is anyone able to run me through how the output is 24?
To prove how confused I am, I thought the output would have been 6, 12, 20 ,1
package Examples;
public class QuestionDemo {
public static void main(String[] args) {
System.out.println(recCall(2));
}
public static int recCall(int num) {
if (num == 5) {
return 1;
} else {
return num * recCall(++num);
}
}
}