def get_coin_count(i, k)
  current = i
  coin_count = 0
  loop
    return coin_count if current > k
    current *= 2
    coin_count += 1
  end
end


def f(n, k)
   (1..n).map do |i|
     1/n * (1/2) ** get_coin_count(i, k)
   end.inject(&:+)
end