You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
338 B

#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
double s = 0;
if (n % 2 == 0) {
for (int i = 2; i <= n; i = i + 2)
s += 1.0 / i;
} else {
for (int i = 1; i <= n; i = i + 2)
s += 1.0 / i;
}
cout << s << endl;
return 0;
}