-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10299.cpp
More file actions
48 lines (40 loc) · 1.05 KB
/
10299.cpp
File metadata and controls
48 lines (40 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
#define tani_nachi_ke ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M_PI 3.14159265358979323846
#define data data_
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ld long double
long long phi(long long n)
{
if(n == 1)
return 0;
long long res = n;
for(long long i = 2; i * i <= n; i++)
{
if(n%i == 0)
{
while(n%i == 0)
n/=i;
res -= res/i;
}
}
if(n > 1)
res -= res/n;
return res;
}
int main()
{
tani_nachi_ke
long long n;
while(cin >> n)
{
if(n == 0)
break;
cout << phi(n) << '\n';
}
return 0;
}