code: protected static double luby(double y, int x) {
      int intX = x;
      int size = 1;
      int seq = 0;
      while (size < intX + 1) {
        seq++;
        size = 2 * size + 1;
      }
      while (size - 1 != intX) {
        size = (size - 1) >> 1;
        seq--;
        intX = intX % size;
      }
      return Math.pow(y, seq);
    }
docs: Computes the next number in the Luby sequence.
  @param y the restart increment
  @param x the current number of restarts
  @return the next number in the Luby sequence