import std.stdio;
import std.algorithm;
import std.functional;

void main() {
    double[] dp = new double[100001];
    dp[0] = 0.0;
    dp[1] = 1.0;
    dp[2] = 1.5;
    double a = 1.0 / 8.0, 
           b = 3.0 / 8.0,
           c = 1.0 / 2.0;
    foreach (i; 3 .. 100000) {
        dp[i] = a * 1.0 + b * 0 + c * dp[i - 2] + dp[i - 1];
        double next_a = a / (1 << i);
        double next_b = a - next_a;
        c = b;
        a = next_a;
        b = next_b;
    }
    int n;
    while (readf("%d\n", &n), n) {
        printf("%5f\n", dp[n]);
    }
}