java - Can't understand the result of recursion -



java - Can't understand the result of recursion -

i have code:

public static void main(string[] args) { system.out.println(f(4)); } public static int f(int n){ if(n == 1) homecoming 1; homecoming n / f(n - 1); }

why code homecoming 4 ?

f(1) explicitly homecoming 1

f(2) give 2/f(1)==2/1==2

f(3) give 3/f(2)==3/2==1 (int division)

f(4) give 4/f(3)==4/1==4

java recursion

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -