?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Recursive Method Which Adds Values

APCSA-E44YE6

Consider the following method.

public static int mystery(int x)
{
    if (x > 0)
        return x + mystery(x - 1);
    return 0;
}

Which of the following is returned when mystery(5) is called?

A

0

B

14

C

15

D

16

E

21