用错位相减法。
记 S = (1/n)[1·2^0 + 2·2^1 + 3·2^2 + ...... + (h-1)·2^(h-2) + h·2^(h-1)],
两边同乘以 2,得
2S = (1/n)[ 1·2^1 + 2·2^2 + ...... + (h-2)·2^(h-2) + (h-1)·2^(h-1) + h·2^h],
下式减去上式, 注意 2 的同幂次相减,得
S = (1/n)[-1 - 2^1 - 2^2 - ...... - 2^(h-2) - 2^(h-1) + h·2^h ],
除两头项外, 中间所有项成等比数列, 公比为 2, 则得
S = (1/n){h·2^h -1 - 2·[2^(h-1)-1]/(2-1)}
= (1/n)[h·2^h -1 - 2^h + 2] = (1/n)[1+(h-1)·2^h]
温馨提示:答案为网友推荐,仅供参考