This commit is contained in:
HuangHai
2025-08-30 18:35:01 +08:00
commit 1f397eca87
6258 changed files with 1487241 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const ULL mod = 1000000007;
ULL euler(ULL n) {
ULL res = n, a = n;
for (ULL i = 2; i * i <= a; i++) {
if (a % i == 0) {
res = res / i * (i - 1);
while (a % i == 0) a /= i;
}
}
if (a > 1) res = res / a * (a - 1);
return res;
}
int main() {
ULL n;
while (~scanf("%llu", &n), n) {
ULL sum = n * (1 + n) / 2 - n, ans;
ans = sum - euler(n) * n / 2;
printf("%llu\n", ans % mod);
}
return 0;
}