Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int i, n;
- float sum = 0;
- cout << "Enter the value of n: ";
- cin >> n;
- for (i=1; i<=n; i++)
- sum += 1.0/pow(i,2);
- cout << "Sum: " << sum;
- return 0;
- }
- for (i=1; i<=n; i++)
- sum += pow(2,-i);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement