Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i, n;
  8. float sum = 0;
  9.  
  10. cout << "Enter the value of n: ";
  11. cin >> n;
  12.  
  13. for (i=1; i<=n; i++)
  14. sum += 1.0/pow(i,2);
  15.  
  16. cout << "Sum: " << sum;
  17.  
  18.  
  19. return 0;
  20. }
  21.  
  22. for (i=1; i<=n; i++)
  23. sum += pow(2,-i);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement