Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What does int S(int n) mean?
What does int S(int n) mean?
S is a recursive function. If you enter n, the final result returned by s is the value of 1+2+ ...+n.

For the s function, analyze it like this.

1 If n is 1, directly return 1.

2 If n is not 1, then n+S(n- 1) is returned.

Then, continue to look down, s (n) = n+s (n- 1), s (n- 1) = n- 1+s (n-2), continue to push, there are:

s(n)= n+n- 1+n-2+……+4+3+2+ 1

Finally, the result is returned.