#include <bits/stdc++.h>
double dp[2][1005];
int min(int x, int y) { return x < y ? x : y; }
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int p = 0, q = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= min(1000, n - i + 1); ++j) {
      dp[q][j] = (k - 1.0) / k * dp[p][j] +
                 1.0 / k / (j + 1) * (dp[p][j + 1] + j) +
                 1.0 / k / (j + 1) * (dp[p][j] * j + (1.0 + j) * j / 2.0);
    }
    p ^= 1, q ^= 1;
  }
  printf("%.10f\n", dp[p][1] * k);
  return 0;
}
