In recursive function developed using java is below.
public class Base {
public static void main(String[] arg) {
m1(4);
}
public static void m1(int num) {
if(num>=1) {
System.out.println("----A "+num);
return num*m1(num-1);
else {
return 1;
}
}
}
Here, when calling m1(num-1), how num value is assigned to num-1. Example, num =4 , next time num value will be num =3. I mean here , we wont assign as num = 3 although we call m1() function. When calling function m1(), it is stored in the stack, so it will become f(3). I can understand that. But I am confused how num value is assigned to a new value.Could you please explain?.