Jump to content

The sum of the series


Genady

Recommended Posts

How did you solve it?

 

I noticed a pattern in what each subsequent term was "leaving out", and figured out a formula for the sum of the first n terms, then used induction to see that it works as n goes to infinity. Is there another way?

Link to comment
Share on other sites

1 hour ago, md65536 said:

How did you solve it?

Spoiler
// Compile:
// gcc math.cpp -o math
//
// Execute:
// ./math

#include <stdio.h>

int main( void ) {
 double accum = 0;
 for( int i = 2; i < 100000; i++ ) {
  //printf( "%c1/(%dx%d)\n", i==2 ? ' ' : '+', i-1, i );
  accum += 1.0 / ( (i-1)*i );
 }
 printf( "Sum %g\n", accum );
 return( 0 );
}

..for the first 100,000..

Quote

+1/(99994x99995)
+1/(99995x99996)
+1/(99996x99997)
+1/(99997x99998)
+1/(99998x99999)
Sum 0.999965

TODO: replace 'double' by a type from some arbitrary precision library.

https://en.wikipedia.org/wiki/List_of_C%2B%2B_multiple_precision_arithmetic_libraries

 

Edited by Sensei
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.