import sys sys.setrecursionlimit(10**6) import pypyjit pypyjit.set_param('max_unroll_recursion=-1') class Eratosthenes: def __init__(self, n): self.isPrime = [True]*(n+1) self.minfactor = [-1]*(n+1) self.isPrime[0], self.isPrime[1] = False, False self.minfactor[1] = 1 for i in range(2, n+1): if self.isPrime[i]: self.minfactor[i] = i for j in range(i*2, n+1, i): self.isPrime[j] = False if self.minfactor[j] == -1: self.minfactor[j] = i def factorize(self, n): factor = [] while n > 1: p = self.minfactor[n] cnt = 0 while self.minfactor[n] == p: n //= p cnt += 1 factor.append((p, cnt)) return factor def divisor(self, n): ans = [1] pf = self.factorize(n) for p, c in pf: L = len(ans) for i in range(L): v = 1 for _ in range(c): v *= p ans.append(ans[i]*v) return sorted(ans) def factorization2(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i == 0: cnt = 0 while temp%i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr def Euler(n): if n > 10**6: fact = factorization2(n) else: fact = E.factorize(n) ans = n for n, c in fact: ans *= 1-(1/n) return ans def divisor2(n): ans = [] for i in range(1, int(n**0.5)+1): if n % i == 0: ans.append(i) if i*i != n: ans.append(n//i) return sorted(ans) N = int(input()) def dfs(n): if n in D: return D[n] if n > 10**6: div = divisor2(n) else: div = E.divisor(n) cnt = [0]*(len(div)-2) for i in range(len(div)-2): cnt[i] = Euler(n//div[i+1]) SUM = 0 for i in range(len(cnt)): SUM += dfs(div[i+1])*(cnt[i]/(n-1)) D[n] = SUM+n/(n-1) return D[n] E = Eratosthenes(min(10**6, N)) D = dict() print(dfs(N))