public class Euler527 {

    static double harmonicAsymptotic(long n) {
        double kGamma = 0.577215664901532860606512090082402431;
        double nn = (double) n;
        double inv = 1.0 / nn;
        double inv2 = inv * inv;
        double inv4 = inv2 * inv2;
        return Math.log(nn) + kGamma + 0.5 * inv - (1.0 / 12.0) * inv2 + (1.0 / 120.0) * inv4;
    }

    static double harmonicNumber(long n) {
        if (n <= 1000000) {
            double s = 0.0;
            for (long k = 1; k <= n; k++) {
                s += 1.0 / (double) k;
            }
            return s;
        }
        return harmonicAsymptotic(n);
    }

    static double expectedRandomBinarySearch(long n) {
        double Hn = harmonicNumber(n);
        double nn = (double) n;
        return 2.0 * (nn + 1.0) / nn * Hn - 3.0;
    }

    static double expectedStandardBinarySearch(long n) {
        int h = 63 - Long.numberOfLeadingZeros(n);
        long twoH1 = 1L << (h + 1);
        double nn = (double) n;
        return (double) (h + 1) - ((double) twoH1 - (double) (h + 2)) / nn;
    }

    public static void main(String[] args) {
        long n = 10000000000L;
        double B = expectedStandardBinarySearch(n);
        double R = expectedRandomBinarySearch(n);
        double ans = R - B;
        System.out.printf(java.util.Locale.US, "%.8f\n", ans);
    }
}
