#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
int n, nxt[MAXN], mobius[MAXN];
double f[MAXN], logFact[MAXN];
double logC(int n, int k) {
return logFact[n] - logFact[k] - logFact[n-k];
}
double getGcdProbability(int d, int k) {
int cnt1 = n%d;
int cnt0 = d - cnt1;
int n0 = n / d;
int n1 = n0 + 1;
double ans = 0;
if (n0 >= k)
//C(n0, k) * cnt0 / C(n, k)
ans += exp(logC(n0, k) - logC(n, k) + log(cnt0));
if (n1 >= k)
//C(n1, k) * cnt1 / C(n, k)
ans += exp(logC(n1, k) - logC(n, k) + log(cnt1));
return ans;
}
int main() {
n = 1000000;
for(int i = 2; i <= n; ++i) {
if (nxt[i] != 0)
continue;
for(int j = i; j <= n; j += i)
if (nxt[j] == 0)
nxt[j] = i;
}
for(int i = 1; i <= n; ++i) {
mobius[i] = 1;
int x = i;
while (x > 1) {
int p = nxt[x], cnt = 0;
while (nxt[x] == p) {
++cnt;
x /= p;
}
if (cnt >= 2)
mobius[i] = 0;
else
mobius[i] *= -1;
}
}
logFact[0] = 0;
for(int i = 1; i <= n; ++i)
logFact[i] = logFact[i-1] + log(i);
for(int k = 2; k <= 30; ++k) {
double P = 0;
for(int i = 1; i <= n; ++i)
P += getGcdProbability(i, k) * mobius[i];
printf("%d %.9g\n", k, 1 - P);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWE4gPSAxMDAwMDA1OwoKaW50IG4sIG54dFtNQVhOXSwgbW9iaXVzW01BWE5dOwpkb3VibGUgZltNQVhOXSwgbG9nRmFjdFtNQVhOXTsKCmRvdWJsZSBsb2dDKGludCBuLCBpbnQgaykgewogICAgcmV0dXJuIGxvZ0ZhY3Rbbl0gLSBsb2dGYWN0W2tdIC0gbG9nRmFjdFtuLWtdOwp9Cgpkb3VibGUgZ2V0R2NkUHJvYmFiaWxpdHkoaW50IGQsIGludCBrKSB7CiAgICBpbnQgY250MSA9IG4lZDsKICAgIGludCBjbnQwID0gZCAtIGNudDE7CiAgICBpbnQgbjAgPSBuIC8gZDsKICAgIGludCBuMSA9IG4wICsgMTsKCiAgICBkb3VibGUgYW5zID0gMDsKICAgIGlmIChuMCA+PSBrKQogICAgICAgIC8vQyhuMCwgaykgKiBjbnQwIC8gQyhuLCBrKQogICAgICAgIGFucyArPSBleHAobG9nQyhuMCwgaykgLSBsb2dDKG4sIGspICsgbG9nKGNudDApKTsKICAgIGlmIChuMSA+PSBrKQogICAgICAgIC8vQyhuMSwgaykgKiBjbnQxIC8gQyhuLCBrKQogICAgICAgIGFucyArPSBleHAobG9nQyhuMSwgaykgLSBsb2dDKG4sIGspICsgbG9nKGNudDEpKTsKCiAgICByZXR1cm4gYW5zOwp9CgppbnQgbWFpbigpIHsKICAgIG4gPSAxMDAwMDAwOwogICAgZm9yKGludCBpID0gMjsgaSA8PSBuOyArK2kpIHsKICAgICAgICBpZiAobnh0W2ldICE9IDApCiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIGZvcihpbnQgaiA9IGk7IGogPD0gbjsgaiArPSBpKQogICAgICAgICAgICBpZiAobnh0W2pdID09IDApCiAgICAgICAgICAgICAgICBueHRbal0gPSBpOwogICAgfQoKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgbW9iaXVzW2ldID0gMTsKICAgICAgICBpbnQgeCA9IGk7CgogICAgICAgIHdoaWxlICh4ID4gMSkgewogICAgICAgICAgICBpbnQgcCA9IG54dFt4XSwgY250ID0gMDsKICAgICAgICAgICAgd2hpbGUgKG54dFt4XSA9PSBwKSB7CiAgICAgICAgICAgICAgICArK2NudDsKICAgICAgICAgICAgICAgIHggLz0gcDsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgaWYgKGNudCA+PSAyKQogICAgICAgICAgICAgICAgbW9iaXVzW2ldID0gMDsKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgbW9iaXVzW2ldICo9IC0xOwogICAgICAgIH0KICAgIH0KCiAgICBsb2dGYWN0WzBdID0gMDsKICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKQogICAgICAgIGxvZ0ZhY3RbaV0gPSBsb2dGYWN0W2ktMV0gKyBsb2coaSk7CgogICAgZm9yKGludCBrID0gMjsgayA8PSAzMDsgKytrKSB7CiAgICAgICAgZG91YmxlIFAgPSAwOwogICAgICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbjsgKytpKQogICAgICAgICAgICBQICs9IGdldEdjZFByb2JhYmlsaXR5KGksIGspICogbW9iaXVzW2ldOwoKICAgICAgICBwcmludGYoIiVkICUuOWdcbiIsIGssIDEgLSBQKTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=