## https://yukicoder.me/problems/no/2829 import math def main(): N = int(input()) # 約数の列挙 sqrt_n = int(math.sqrt(N)) divisors = [] for p in range(1, sqrt_n + 1): if N % p == 0: q = N // p divisors.append(p) if q != p: divisors.append(q) # 各divisorたちのgcdとその分布を計算 divisors.sort() gcds = [] for i in range(len(divisors)): d = divisors[i] a_map = {} for j in reversed(range(i + 1)): d_ = divisors[j] if d % d_ > 0: continue q = d // d_ for k in range(j + 1, i + 1): if d % divisors[k] == 0 and divisors[k] % d_ == 0: q -= a_map[divisors[k]] a_map[d_] = q gcds.append(a_map) dp = {1:0} for i in range(len(divisors)): s = divisors[i] if s == 1: continue ans = s for key, value in gcds[i].items(): if key == s: continue ans += value * dp[key] ans /= s - 1 dp[s] = ans print(dp[N]) if __name__ == "__main__": main()