Ask Question
26 May, 08:23

Public static int recur (int x) { if (x > = 0) return x + recur (x - 1); return 0; } What is returned by the method call recur (9) ?

+4
Answers (1)
  1. 26 May, 10:52
    0
    9 > = 0 so return 9 + ...

    8 > = 0 so return 8 + ...

    7 > = 0 so return 7 + ...

    6 > = 0 so return 6 + ...

    5 > = 0 so return 5 + ...

    4 > = 0 so return 4 + ...

    3 > = 0 so return 3 + ...

    2 > = 0 so return 2 + ...

    1 > = 0 so return 1 + ...

    0 > = 0 so return 0 + ...

    -1 is not > = 0 so return 0.

    Now string together all the returns ...

    9+8+7+6+5+4+3+2+1+0+0=45

    recur (9) returns 45
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Public static int recur (int x) { if (x > = 0) return x + recur (x - 1); return 0; } What is returned by the method call recur (9) ? ...” in 📙 Advanced Placement (AP) if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers