0
How will the program execute this code?
static int Fact(int num) { if (num == 1) { return 1; } return num * Fact(num - 1);} Like this: //(Num= 4) static int Fact(int 4) { if (num == 1) { return 1; } return 4 * Fact(4 - 1)=—> Return 4 * Fact(4-1)=3 * Fact(3-1)= 2 * Fact(2-1 if num ==1) = 1 Or will it behalve more like a loop: static int Fact(int 4* fact(3)*Fact(2) etc) { if (4 == 1) { return 1; } return 4 * Fact(num - 1);} Static int Fact( 4*3*2*1){} or Static int Fact(int 4){ 4*3*2*1}
4 Réponses
+ 2
Did you write this code in code playground and insert in this question
0
where will the loop take place?
0
yes sry
0
if u have a method that calls itself wil it then go like a loop up down or wil it go one time down and write it out?