Limited access

Upgrade to access all content for this subject

Consider the following method.

public static int mystery(int x)
{
    if (x <=1)
         return 3;
    else
         return 3 * mystery(x-1);
}

Which is the following is returned as a result of the call mystery(q) if q > 0 and q is initialized and defined as an int?

A

$3^q$

B

$3 ^{(q-1)}$

C

$(3^q) - 1$

D

$q^3$

E

$3q$

Select an assignment template