Created
August 30, 2016 16:08
-
-
Save quickgrid/fe63d5e0649abe5a0c4515dcbe20b2d1 to your computer and use it in GitHub Desktop.
Code to calculate sum $ \frac{3^2+1}{3^2-1} + \frac{5^2+1}{5^2-1} + \frac{7^2+1}{7^2-1} + ..... + \frac{99^2+1}{99^2-1} $ which is exactly 49.49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main(){ | |
double sum = 0; | |
for(int i = 3; i <= 99; i = i + 2){ | |
sum = sum + ((double) (i*i + 1) /(i*i - 1) ); | |
} | |
printf("%lf\n", sum); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment