Jaehyun wrote the source below.
long long mod = 1000000007;
long long all_pair_lcm(int n) {
long long ans = 0;
for (int i=1; i<=n-1; i++) {
for (int j=i+1; j<=n; j++) {
ans += lcm(i, j);
ans %= mod;
}
}
return ans;
}
lcm(i, j) returns the least common multiple of i and j. When n is large, this double loop does not finish in time.
Given n, write a program that prints the return value of all_pair_lcm(n). That is, add lcm(i,j) over every pair (i,j) with 1≤i<j≤n, then print the remainder of that sum divided by 109+7.