Advertisement
josiftepe

Untitled

Sep 28th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std ;
  3.  
  4. int main() {
  5.     double rezultat = 1.0;
  6.     for(int i = 2; i <= 10000; i++) {
  7.         if(i % 2 == 0) {
  8.             rezultat -= (1.0 / (double) i);
  9.         }
  10.         else {
  11.             rezultat += (1.0 / (double) i);
  12.         }
  13.     }
  14.     cout << rezultat << endl;
  15.     return 0;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement