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

double[][] cache;
double solve(int n, int r) {
    if (r >= 10) return 0.0;
    if (n <= 0) return 0.0;
    if (n == 1) return 1.0;
    if (cache[n][r] != double.max) return cache[n][r];
    if (n == 2) return (1.0 + 1.0 / (1 << (r + 1)));
    return cache[n][r] = 
         1.0 / (1 << r) + 
         solve(n - 1, r + 1) * (1.0 / (1 << (r + 1))) + 
         solve(n - 2, 0) * (1.0 - 1.0 / (1 << (r + 1)));
}

void main() {
    int n;
    cache = new double[][](100001, 10);
    foreach (ref _; cache) _[] = double.max;
    solve(30000, 0);
    solve(60000, 0);
    solve(90000, 0);
    while (readf("%d\n", &n), n) {
        printf("%5f\n", solve(n, 0));
    }
}