public class Euler503 {

    private static double solveExpectedScore(int n) {
        double nextValue = (n + 1.0) / 2.0;

        for (int t = n - 1; t >= 1; --t) {
            double slope = (n + 1.0) / (t + 1.0);
            double cutoff = nextValue / slope;

            int k = (int) Math.floor(cutoff + 1e-15);
            if (k < 0)
                k = 0;
            if (k > t)
                k = t;

            double sumRanks = k * (k + 1.0) / 2.0;
            double stopExpectation = slope * sumRanks;
            double continueExpectation = (t - k) * nextValue;

            nextValue = (stopExpectation + continueExpectation) / t;
        }
        return nextValue;
    }

    public static void main(String[] args) {
        int n = 1000000;
        double answer = solveExpectedScore(n);
        System.out.printf(java.util.Locale.US, "%.10f\n", answer);
    }
}
