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

double solve(int n) {
    if (n <= 0) return 0.0;
    if (n == 1) return 1.0;
    if (n == 2) return 1.5;
    double ans = 1.0;
    if (n >= 2) {
        ans += (1.0 / 2) * solve(n - 2);
        ans += (1.0 / 2);
    }
    if (n >= 3) {
        ans += (1.0 / 2) * (3.0 / 4) * solve(n - 3);
        ans += (1.0 / 2) * (1.0 / 4);
    }
    if (n >= 4) {
        ans += (1.0 / 2) * (1.0 / 4) * (7.0 / 8) * solve(n - 4);
        ans += (1.0 / 2) * (1.0 / 4) * (1.0 / 8);
    }
    if (n >= 5) {
        ans += (1.0 / 2) * (1.0 / 4) * (1.0 / 8) * (15.0 / 16) * solve(n - 5);
        ans += (1.0 / 2) * (1.0 / 4) * (1.0 / 8) * (1.0 / 16);
    }
    return ans;
}

void main() {
    int n;
    while (readf("%d\n", &n), n) {
        printf("%5f\n", solve(n));
    }
}