makhdoom ghaya
asked
Oct 6, 2015
1,790
views
TIFR CSE 2010 | Part B | Question: 24
Consider the following program operating on four variables $u, v, x, y$, and two constants $X$ and $Y$. x, y, u, v:= X, Y, Y, X; While (x ≠ y) do if (x > y) then x, v := x - y, v + u; else if (y > x) then y, u:= y ... . The program prints $\frac1 2 \times \text{gcd}(X, Y)$ followed by $\frac1 2 \times \text{lcm}(X, Y)$. The program does none of the above.
Consider the following program operating on four variables $u, v, x, y$, and two constants $X$ and $Y$.x, y, u, v:= X, Y, Y, X; While (x ≠ y) do if (x y) then x, v := ...