题目
In this question, the function INT() is the largest integer less than or equal to . For example, INT(5.7) = 5, INT(8) = 8, INT(−2.3) = −3.
Consider the following algorithm.
Step 1: Input
Step 2: Calculate
Step 3: Let = INT()
Step 4: Calculate
Step 5: Calculate
Step 6: Output
Step 7: Replace by
Step 8: If then STOP, otherwise go back to Step 2
(a) Complete the table in the answer book, using , to show the results obtained at each step of the algorithm.
(b) Explain how the output values of the algorithm relate to the original input , where is any positive integer.
题目中文翻译
在此问题中,函数 INT() 是小于或等于 的最大整数。例如,INT(5.7) = 5,INT(8) = 8,INT(−2.3) = −3。
考虑以下算法。
第 1 步:输入
第 2 步:计算
第 3 步:设 = INT()
第 4 步:计算
第 5 步:计算
第 6 步:输出
第 7 步:用 替换
第 8 步:如果 则停止,否则回到第 2 步
(a) 使用 完成答案本中的表格,显示算法每一步获得的结果。
(b) 解释算法的输出值与原始输入 之间的关系,其中 是任意正整数。