Question: public static int mystery ( int n ) { Random r = new Random ( ) ; int a = r . nextInt ( 3

public static int mystery(int n){
Random r = new Random();
int a = r.nextInt(3)+1;
int b =2;
// Point A
while (n > b){
// Point B
b = b + a;
if (a >1){
n--;
// Point C
a = r.nextInt(b)+1;
} else {
a = b +1;
// Point D
}
}
// Point E
return n;
}
Categorize each assertion at each point with ALWAYS, NEVER, or SOMETIMES:
n > b
a >1
b > a
Point A
Point B
Point C
Point D
Point E

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!