#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  char ch = getchar();
  T x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
double f[2][1009];
int main(int argc, char const *argv[]) {
  int n = read<int>(), k = read<int>();
  int temp = 1;
  for (int(i) = (1); (i) <= (n); (i)++) {
    for (int(j) = (min(n, 1000)); (j) >= (1); (j)--)
      f[temp][j] = ((f[temp ^ 1][j + 1] + j) / (j + 1.0) +
                    j * (f[temp ^ 1][j] + (j + 1.0) / 2.0) / (j + 1.0)) /
                       (double)k +
                   (k - 1) * f[temp ^ 1][j] / (double)k;
    temp ^= 1;
  }
  printf("%.10lf\n", k * f[temp ^ 1][1]);
  return 0;
}
