#P2303. Sum of GCDs

    ID: 15577 Type: Default 1000ms 256MiB

Sum of GCDs

Sum of GCDs

Given an integer n, compute the sum

$$\sum\limits_{i=1}^{n} \gcd(i, n)$$

where $$\gcd(i, n)$$ denotes the greatest common divisor of i and n.

inputFormat

The input consists of a single integer n (1 ≤ n ≤ 106).

outputFormat

Output a single integer which is the sum of $$\gcd(i, n)$$ for all i from 1 to n.

sample

1
1