Genady Posted April 29, 2023 Share Posted April 29, 2023 PS. @Boltzmannbrain, since you seem to like infinities, you might find it interesting. Link to comment Share on other sites More sharing options...
Boltzmannbrain Posted April 29, 2023 Share Posted April 29, 2023 Yeah, these are fun. Link to comment Share on other sites More sharing options...
md65536 Posted April 30, 2023 Share Posted April 30, 2023 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 More sharing options...
Sensei Posted April 30, 2023 Share Posted April 30, 2023 (edited) 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 April 30, 2023 by Sensei Link to comment Share on other sites More sharing options...
Genady Posted April 30, 2023 Author Share Posted April 30, 2023 4 hours ago, md65536 said: Is there another way? Yes, there is. Here is a hint: Spoiler See where it goes? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now