#include #include #include #include using namespace std; int gcd (int x, int y) { while (0 < x) { int t = x; x = y % x; y = t; } return y; } int main () { int N; cin >> N; vector memo(N + 1, -1); auto E = [&] (auto self, int x) -> double { if (memo[x] != -1) return memo[x]; if (x == 1) return 0; double res = 1; for (int v = 1; v < x; v++) { res += 1 + self(self, gcd(v, x)); } return memo[x] = res / (x - 1); }; cout << setprecision(10); cout << E(E, N) << "\n"; }