?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Easy

For Loop with Integer Parameter

APCSA-VNYWTK

Consider the following method.

    //Precondition: x >= 0
    public static int mystery(int x)
    {
        int z = 1;
        for (int i = 1; i <=x; i++)
            z*=i;
        return z;
   }

Which of the following is returned by the call mystery(5) ?

A

1

B

24

C

60

D

120

E

720