題目
Problem
6. Consider the following sequence of instructions.
- Set , , and .
- If , then go to step 3; otherwise go to step 5.
- Replace with and replace with .
- Go to step 2.
- Print .
If these instructions are followed, what number will be printed at step 5?
(A) (B) (C) (D) (E)
解答
解法一
思路
展開
- 每執行一輪就把 加倍,將停止條件改寫成對 的比較。
答題過程
展開
從 開始,執行 輪後 。由於 ,第 輪才使 不成立。因此程式印出 ,選 。