记a=2分之一加4分之3加8分之7加16分之15加……加512分之511

2024-12-04 04:12:05
推荐回答(2个)
回答1:

a=1/2+3/4+7/8+15/16+……+511/512

=9-(1/2+1/4+……+1/128+1/256+ 1/512+ 1/512- 1/512)
=9-[1/2+1/4+……+1/128+1/256+ (1/512+ 1/512)- 1/512]
=9-[1/2+1/4+……+1/128+1/256+ (2/512)- 1/512]
=9-{1/2+1/4+……+1/128+[1/256+ (1/256)]- 1/512}
=9-[1/2+1/4+……1/128+1/128-1/512]      (这里的规律就是分出一个1/512后 无限与前面合并)
……

已知 2^9=512  所以 一共需要9个1来减
=9-(1/2+1/4+1/4-1/512)
=9-(1/2+1/2-1/512)
=9-511/512
=4097/512


代码验证答案如下

                  ↑  这是算出来的答案 

回答2:

a=1/2+3/4+7/8+15/16+……+511/512
=1-1/2+1-1/4+……+1-1/512
=9-(1/2+1/2^2+1/2^3+……+1/2^9)
=9-(1/2x(1-1/2^9))/(1-1/2)
=9-511/512
=4097/512