import java.util.Arrays;

public class Euler869 {

    static final int TERM_BIT = 0x80000000;
    static final int CNT_MASK = 0x7fffffff;

    static class PrimeGuessing {
        int limit;
        int[] child0;
        int[] child1;
        int[] cntTerm;
        int nodeCount;

        PrimeGuessing(int limit) {
            this.limit = limit;
            int capacity = 32000000;
            child0 = new int[capacity];
            child1 = new int[capacity];
            cntTerm = new int[capacity];
            Arrays.fill(child0, -1);
            Arrays.fill(child1, -1);
            nodeCount = 1; // root node
            build();
        }

        int addNode() {
            if (nodeCount == child0.length) {
                int newCap = child0.length * 2;
                child0 = Arrays.copyOf(child0, newCap);
                child1 = Arrays.copyOf(child1, newCap);
                cntTerm = Arrays.copyOf(cntTerm, newCap);
                for (int i = nodeCount; i < newCap; i++) {
                    child0[i] = -1;
                    child1[i] = -1;
                }
            }
            return nodeCount++;
        }

        void insertPrime(int p) {
            int u = 0;
            cntTerm[u] = (cntTerm[u] & TERM_BIT) | ((cntTerm[u] & CNT_MASK) + 1);

            int len = 32 - Integer.numberOfLeadingZeros(p);
            for (int d = 0; d < len; ++d) {
                int b = (p >> d) & 1;
                int v;
                if (b == 0) {
                    v = child0[u];
                    if (v == -1) {
                        v = addNode();
                        child0[u] = v;
                    }
                } else {
                    v = child1[u];
                    if (v == -1) {
                        v = addNode();
                        child1[u] = v;
                    }
                }

                u = v;
                cntTerm[u] = (cntTerm[u] & TERM_BIT) | ((cntTerm[u] & CNT_MASK) + 1);
            }
            cntTerm[u] |= TERM_BIT;
        }

        void build() {
            if (limit >= 2)
                insertPrime(2);
            if (limit < 3)
                return;

            int m = (limit >> 1) + 1;
            byte[] isPrime = new byte[m];
            Arrays.fill(isPrime, (byte) 1);
            isPrime[0] = 0;

            int r = (int) Math.sqrt(limit);
            for (int p = 3; p <= r; p += 2) {
                if (isPrime[p >> 1] == 0)
                    continue;
                int step = p << 1;
                for (int x = p * p; x <= limit && x > 0; x += step) {
                    isPrime[x >> 1] = 0;
                }
            }

            for (int p = 3; p <= limit; p += 2) {
                if (isPrime[p >> 1] == 1) {
                    insertPrime(p);
                }
            }
        }

        double dfs(int u) {
            int ct = cntTerm[u];
            int total = ct & CNT_MASK;
            int term = (ct >>> 31);
            int cont = total - term;
            if (cont == 0)
                return 0.0;

            int c0 = 0, n0 = 0;
            double v0 = 0.0;

            int ch0 = child0[u];
            if (ch0 != -1) {
                int ct0 = cntTerm[ch0];
                c0 = ct0 & CNT_MASK;
                n0 = c0 - (ct0 >>> 31);
                if (n0 > 0)
                    v0 = dfs(ch0);
            }

            int c1 = 0, n1 = 0;
            double v1 = 0.0;

            int ch1 = child1[u];
            if (ch1 != -1) {
                int ct1 = cntTerm[ch1];
                c1 = ct1 & CNT_MASK;
                n1 = c1 - (ct1 >>> 31);
                if (n1 > 0)
                    v1 = dfs(ch1);
            }

            double denom = (double) cont;
            double score = Math.max(c0, c1) / denom;
            score += (n0 / denom) * v0;
            score += (n1 / denom) * v1;
            return score;
        }

        double expectation() {
            return dfs(0);
        }
    }

    public static String solve() {
        PrimeGuessing pg = new PrimeGuessing(100000000);
        return String.format(java.util.Locale.US, "%.8f", pg.expectation());
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
