#include <bits/stdc++.h>
using namespace std;
long n, k;
double prob[10][1000 + 100];
double ans;
double ev[10][1000 + 100];
double pup, prem;
double rev[100000];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  double gz = 1.0 / k;
  for (int i = 1; i <= 1000 + 1000; i++) rev[i] = 1.0 / i;
  prob[0][1] = 1;
  ev[0][1] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 1000; j++) prob[1 - i % 2][j] = ev[1 - i % 2][j] = 0;
    long ths, nxt;
    ths = i % 2;
    nxt = 1 - ths;
    for (int j = 1; j <= 1000; j++) {
      if (prob[ths][j] < 1e-50) continue;
      ev[ths][j] /= prob[ths][j];
      pup = gz * rev[j + 1];
      prob[nxt][j + 1] += prob[ths][j] * pup;
      ev[nxt][j + 1] += (ev[ths][j] + j) * prob[ths][j] * pup;
      prem = gz * (1.0 - rev[j + 1]);
      prob[nxt][j] += prob[ths][j] * prem;
      ev[nxt][j] += (ev[ths][j] + (j + 1) * 0.5) * prob[ths][j] * prem;
      prob[nxt][j] += prob[ths][j] * (1.0 - gz);
      ev[nxt][j] += ev[ths][j] * (1.0 - gz) * prob[ths][j];
    }
  }
  for (int i = 1; i <= 1000; i++) ans += ev[n % 2][i] * k;
  cout.precision(12);
  cout << fixed << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
