Spicke

Project Number 6

Dec 13th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     setlocale(LC_ALL, "Russian");
  8.     int N;
  9.     double sum = 1.0;
  10.     cout << "Введите N: ";
  11.     cin >> N;
  12.     for (int i = 2; i <= N; i++) {
  13.         sum = sum + (1.0 / i);
  14.     }
  15.     cout << "Сумма равна: "  << fixed << sum << endl;
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment