Free Version

Upgrade subject to access all content

Moderate

Recursive Method: Counting the Number of Calls

APCSA-YELPTE

Consider the following method.

public static int crush(int x)
{
    if(x < 1)
        return 1;
    else
        return x + crush(x-1);
}

Including this first call of crush, how many times is the crush method called when the following statement is executed?

crush(4);
A

1

B

2

C

3

D

4

E

5