mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
34 lines
582 B
C++
34 lines
582 B
C++
|
#include <stdio.h>
|
||
|
using namespace std;
|
||
|
#define N 100000001
|
||
|
int euler(int n)
|
||
|
{
|
||
|
int ans=1;
|
||
|
int i;
|
||
|
for(i=2;i*i<=n;i++)
|
||
|
{
|
||
|
if(n%i==0)
|
||
|
{
|
||
|
n/=i;
|
||
|
ans*=i-1;
|
||
|
while(n%i==0)
|
||
|
{
|
||
|
n/=i;
|
||
|
ans*=i;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if(n>1)
|
||
|
ans*=n-1;
|
||
|
return ans;
|
||
|
}
|
||
|
int main()
|
||
|
{
|
||
|
int n;
|
||
|
while(scanf("%d",&n),n)
|
||
|
{
|
||
|
printf("%d\n",n-1-euler(n));
|
||
|
}
|
||
|
return 0;
|
||
|
}
|