(1)
H1 = 784
H2 = 49
H3 = 160
H4 = 5
H5 = 28
H6 = 7
H7 = 34
H8 = 17
H9 = 64
H10 = 1
H11 = 16
H12 = 1
H13 = 16
……
从第10次运算往后,都是1、16、1、16的循环.
(257 - 10 )÷ 2 余1,因此H257 = 16
(2)
显然,3A + 13 = A×2^M
当M = 1时,3A + 13 = 2A,解得A = -13(舍弃)
当M = 2时,3A + 13 = 4A,解得A = 13
当M = 3时,3A + 13 = 8A,解得A = 13/5(舍弃)
当M = 4时,3A + 13 = 16A,解得A = 1
当M > 4时,A = 13/(2^M - 3),这个分母显然大于13,A必小于1,不可能有解.
综上,A = 13或1.
也就是:
输入1时,H1 = 16,H2 = 1,H3 = 16,H4 = 1……
输入13时,H1 = 52,H2 = 13,H3 = 52,H4 = 13……