74.0k views
2 votes
Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar.

PH
var num2 = 32;
var num1 = 12;
var rem=num2 % numi;
while(rem > 0)
{
num2 = num1;
num1 = rem;
rem = num2 % num1;
}
document.write(num1);
The output of the document.write statement at the end of this block is

User Zakelfassi
by
3.8k points

2 Answers

2 votes

Answer:

Below is correct, the answer is 4.

Step-by-step explanation:

PLATO

Type the correct answer in the box. Use numerals instead of words. If necessary, use-example-1
User Arsalan
by
3.1k points
5 votes

Answer:

4

Step-by-step explanation:

Given

The attached code segment

Required

The output

The first and second lines initialize num2 to 32 and num1 to 12, respectively.

Next, the remainder is calculated on line 3


rem = 32\%12


rem = 8

Then the while loop is repeated as long as rem > 0.

At first, we have:


num2 = 32


num1 = 12


rem = 8

The first iteration gives:


num2 = 12


num1 = 8


rem = 12\%8 = 4

Is 4 > 0? Yes; The loop is executed again.

This gives:


num2 = 8


num1 = 4


rem = 8\%4=0

Is 0 > 0? No; The loop is executed

The last statement prints the last value of num1;

In the last loop, we have:


num1 = 4

Hence, the output is 4

User Levarius
by
3.5k points