#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,abm,mmx,tune=native")
using namespace std;
const int64_t INF = (int64_t)(2e18);
const int inf = (int)(1e9 + 7);
const int maxn = 500 * 1000 + 100;
chrono::time_point<chrono::steady_clock> cl;
double current_time() {
  return (double)(chrono::steady_clock::now() - cl).count() / 1e9;
}
int n, k;
const int magic = 1500;
double e[2][magic];
int32_t main() {
  cl = chrono::steady_clock::now();
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  long double res = 0;
  cin >> n >> k;
  for (int ii = 0; ii < n; ++ii) {
    int i = ii % 2;
    fill(&e[i ^ 1][0], &e[i ^ 1][magic], 0.0);
    for (int x = 1; x < magic - 5; ++x) {
      e[i ^ 1][x] += 1.0 * (k - 1) / k * e[i][x];
      double p = 1.0 / (x + 1) * (x + e[i][x + 1]);
      p += 1.0 * x / (x + 1) * e[i][x];
      p += 1.0 * x / 2;
      e[i ^ 1][x] += p / k;
    }
  }
  cout << k * e[n % 2][1];
  return 0;
}
