|
@@ -0,0 +1,43 @@
|
|
|
+#include<bits/stdc++.h>
|
|
|
+
|
|
|
+using namespace std;
|
|
|
+using LL=long long;
|
|
|
+const int MAXN = 2e6 + 10;
|
|
|
+vector<int> primes = {2, 3};
|
|
|
+
|
|
|
+void init() {
|
|
|
+ for (int k = primes.back() + 2; k <= MAXN; k += 2) {
|
|
|
+ bool flag = true;
|
|
|
+ for (auto p:primes) {
|
|
|
+ if (p * p > k)break;
|
|
|
+ if (k % p == 0) {
|
|
|
+ flag = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag)primes.push_back(k);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int main() {
|
|
|
+ init();
|
|
|
+ for (int n; cin >> n;) {
|
|
|
+ map<int, int> k;
|
|
|
+ for (auto p:primes) {
|
|
|
+ if (p * p > n)break;
|
|
|
+ while (n % p == 0) {
|
|
|
+ ++k[p];
|
|
|
+ n /= p;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (n > 1)k[n]++;
|
|
|
+ LL ans = 1;
|
|
|
+ for (auto p:k) {
|
|
|
+ if (p.second == 1)ans *= (p.first - 1);
|
|
|
+ else ans *= pow(p.first, p.second) - pow(p.first, p.second - 1);
|
|
|
+
|
|
|
+ }
|
|
|
+ cout << ans << endl;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|