local n, p = io.read("*n", "*n") local function getprimes(x) local primes = {} local allnums = {} for i = 1, x do allnums[i] = true end for i = 2, x do if(allnums[i]) then table.insert(primes, i) local lim = math.floor(x / i) for j = 2, lim do allnums[j * i] = false end end end return primes end local function getyakusuu(x, primes) local prime_num = #primes local tmp = {} local lim = math.ceil(math.sqrt(x)) local primepos = 1 local dv = primes[primepos] while(primepos <= prime_num and dv <= lim) do if(x % dv == 0) then tmp[dv] = 1 x = x / dv while(x % dv == 0) do x = x / dv tmp[dv] = tmp[dv] + 1 end lim = math.ceil(math.sqrt(x)) end if(primepos == prime_num) then break end primepos = primepos + 1 dv = primes[primepos] end if(x ~= 1) then tmp[x] = 1 end local cnt = 1 for k, v in pairs(tmp) do cnt = cnt * (v + 1) end return cnt end local tot = 0 local primes = getprimes(n) for i = 2, n do local z = getyakusuu(i, primes) - 2 if(z == 0) then tot = tot + 1 else tot = tot + (1 - p)^z end end print(string.format("%.8f", tot))