ostapdontstop

aslan_1-1

Jan 23rd, 2018
153
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. main()
  4. {
  5.     double s, a, b, t;
  6.     s = a = b = 1;
  7.     int n;
  8.     do {
  9.         cout << "Input n [1 ; 50]: ";
  10.         cin >> n;
  11.     } while ( n < 1 || n > 50 );
  12.  
  13.     for (int i = 1; i < n; i++) {
  14.         t = 2 * a;
  15.         a = t - b;
  16.         b = t + b;
  17.         s += a / b;
  18.     }
  19.     cout << s;
  20. }
RAW Paste Data