Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project Euler #368 (Math Formula) [closed]

In Project Euler, a problem asks me to write a program to find the convergence value of 20 terms from the Harmonic sequence:

1/111, 1/222, 1/333, 1/444, 1/555, 1/666, 1/777, 1/888, 1/999, 1/1000, 1/1110, 1/1111, 1/1112, 1/1113, 1/1114, 1/1115, 1/1116, 1/1117, 1/1118, and 1/1119

I want to write the program myself to solve the problem, however, not having dealt with Calc II, I had to read up on Divergence/Convergence. All the explanations deal with series that can be represented by a formula. This series, as far as I can tell, cannot.

So, the question is:

Is there a formula to represent this series or is there a method for finding the convergence of this series without a formula?

like image 736
Neobane Avatar asked Mar 05 '26 05:03

Neobane


1 Answers

Just in case anybody considers brute-forcing it:

The brute force approach will here, as in most high-numbered Project Euler problems, not finish within reasonable time.

Suppose your computer could handle 109 numbers per second (it can handle far fewer, actually). To sum the valid terms up to 10n for n > 9 would take about 10n-9 seconds.

How far would you have to go to determine the sum to ten places after the decimal point?

Far enough that the sum of all larger valid terms is less than 10-10. Will 1012 be far enough? No. Consider the next thousand numbers from

1001001001001

The invalid numbers among them are

1001001001110
1001001001111
1001001001112
...
1001001001119
1001001001222
1001001001333
1001001001444
...
1001001001999
1001001002000

Those are 19, so there are 981 valid numbers and the corresponding sum is larger than 981/1001001002000, which is more than 9*10-10. A bit of further reasoning along those lines shows that you would have to brute force much higher than 1015 - in fact, you would have to go beyond 102000 before the sum of the remaining valid terms becomes less than 10-10.

A brute force started at the beginning of the universe would not be even remotely near a reliable answer yet.

like image 59
Daniel Fischer Avatar answered Mar 08 '26 01:03

Daniel Fischer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!