文章目錄

原题链接http://projecteuler.net/problem=57

Square root convergents

It is possible to show that the square root of two can be expressed as an infinite continued fraction.

sqrt( 2) = 1 + 1/(2 + 1/(2 + 1/(2 + … ))) = 1.414213…

By expanding this for the first four iterations, we get:

1 + 1/2 = 3/2 = 1.5
1 + 1/(2 + 1/2) = 7/5 = 1.4
1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666…
1 + 1/(2 + 1/(2 + 1/(2 + 1/2))) = 41/29 = 1.41379…

The next three expansions are 99/70, 239/169, and 577/408, but the eighth expansion, 1393/985, is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.

In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?

 

平方根收敛

有可能将2的平方根表示成无限分数:

sqrt(2) = 1 + 1/(2 + 1/(2 + 1/(2 + … ))) = 1.414213…

扩展这个式子的前四项,我们得到

1 + 1/2 = 3/2 = 1.5
1 + 1/(2 + 1/2) = 7/5 = 1.4
1 + 1/(2 + 1/(2 + 1/2)) = 17/12 = 1.41666…
1 + 1/(2 + 1/(2 + 1/(2 + 1/2))) = 41/29 = 1.41379…

之后的三项是99/70,239/169,和577/408,对于第八项,1393/985,是第一个分子中的数字个数超过分母中的数字个数的项

在前1000项中,一共有多少个分数是分子中的数字个数超过分母的?

解答:

就是如何表示分数,之后定义分数的加法,不难。

打赏作者

文章目錄