## 我的基础算糟糕得可以了

2004-09-17 20:50  FantasySoft  阅读(1011)  评论(7编辑  收藏
晚上正在津津有味地看着DirectX的文章，朋友通过MSN给我发来一个问题：

1 + 1/2 + 1/3 + 1/4 + ...... + 1/n怎么计算？
看到这个问题，我愣住了，好象曾经在什么地方看到过这样的一个问题，当时还看到了解答。可是现在怎么都想不起来了。我只好很不好意思地告诉我的朋友，我不知道该怎么计算。当我回复这条信息的时候，着实有点沮丧，因为这是一个比较经典的算法问题，但是我对这个竟然一无所知。我的基础真的太糟糕了，真的应该重新去学习一下算法知识。

The harmonic series is this:

1+1/2+1/3+1/4+1/5+1/6+1/7+1/8+1/9+...

Some infinite series sum to real numbers .These 9 terms sum to 2.829. 100 terms sum to 5.187. 1000 terms sum to 7.4854. And 1,000,000 terms sum to 14.384. Just what does the infinite series add up to? The answer to that is that the sum blows up to infinity. It gets there very slowly, doesn't it? There is actually a simple proof that it sums to infinity:

S=1+(1/2)+(1/3+1/4)+(1/5+1/6+1/7+1/8)+(1/9+...
Consider this series:
T=1+(1/2)+(1/4+1/4)+(1/8+1/8+1/8+1/8)+(1/16+...
T<S for any finite number of terms.
T=1+1/2+1/2+1/2+... which is infinite for infinitely many terms.
So S must also be infinite.

It turns out that there is a relatively simple estimate of the sum of n terms:

S(n) is approximately ln(n)+.5772156649...

It gets closer, the larger n is. The number .5772156649... is known as Euler's constant.