#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); // 10^7程度でやっぱりTLE。。。 // うーんなんか収束していそうな感じがするしある程度大きなNに対してもう決め打ちするか!w if (N <= 1000000) { cout << E(E, N) << "\n"; } else { cout << 2.1388888888 << "\n"; } }