# -*- coding: utf-8 -*- # based http://garnacha.techblog.jp/archives/39531672.html SHULESHOLD = 100 N = SHULESHOLD A = [0] * (N + 1) B = [0] * (N + 1) inv = 1.0 / 6 for i in range(N - 1, -1, -1): for j in range(1, 7): if i + j > N: A[i] += inv B[i] += inv else: A[i] += (A[i + j] + 1) * inv B[i] += B[i + j] * inv T = int(raw_input()) for _ in range(T): N = int(raw_input()) if N < SHULESHOLD: # 98回くらいで誤差が範囲内になった。 ans = A[SHULESHOLD - N] / (1 - B[SHULESHOLD - N]) else: ans = (N + 5 / 3.0) print "%.15f" % ans