The first line is "System.out.println (n +" "+ (n-1)); shows only the values โโof the variable" n "and DOES NOT CONTAIN ANY ARITHMETIC OPERATIONS.
Steps of this function:
6> 1 like this: 6 + fun (5),
5> 1 like this: 6 + 5 + fun (4),
4> 1 like this: 6 + 5 + 4 + fun (3),
3> 1 like this: 6 + 5 + 4 + 3 + fun (2),
2> 1 like this: 6 + 5 + 4 + 3 + 2 + fun (1),
1> = 1 like this: 6 + 5 + 4 + 3 + 2 + 1
and SUM: 6 + 5 + 4 + 3 + 2 + 1 = 21
I hope that my explanations will be useful to you.
source
share