#P1390. Sum of GCDs in All Pairs

    ID: 14677 Type: Default 1000ms 256MiB

Sum of GCDs in All Pairs

Sum of GCDs in All Pairs

Given a positive integer n, compute the following sum:

$$ \sum_{i=1}^{n} \sum_{j=i+1}^{n} \gcd(i,j) $$

Here, \(\gcd(i,j)\) denotes the greatest common divisor of i and j.

inputFormat

The input consists of a single line containing one integer n.

outputFormat

Output one integer, representing the sum of \(\gcd(i, j)\) over all pairs \((i, j)\) with \(1 \le i < j \le n\).

sample

2
1