def solve(N): if N == 1: return 1.0 # dp[i] 表示放置前i張卡片的總期望成本 total_cost = 1.0 # 第1張卡片成本為1 # 當前序列,用於計算中間位置的成本 sequence = [1] for k in range(2, N + 1): # 第k張卡片有k+1個可能位置 positions = k + 1 probability = 1.0 / positions # 最左和最右位置的成本都是1 edge_cost = 2 * probability * 1 # 中間位置的成本計算 middle_cost = 0.0 for i in range(len(sequence) - 1): # 在位置i和i+1之間插入,成本為sequence[i] * sequence[i+1] cost = sequence[i] * sequence[i + 1] middle_cost += probability * cost # 當前卡片的期望成本 current_expected_cost = edge_cost + middle_cost total_cost += current_expected_cost # 更新序列(為了計算下一張卡片,我們需要知道當前可能的序列狀態) # 但實際上我們只需要知道相鄰數字對,可以簡化 sequence.append(k) return total_cost N = int(input()) result = solve(N) print(f"{result:.10f}")