歐拉函數
[cpp]
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std ;
#define INT __int64
int enlerfun( INT n )
{
int tempnum = n ;
for( int i = 2 ; i <= n ; ++i )
{
if( n % i == 0 )
{
tempnum -= tempnum / i ;
while( n % i == 0)
n /= i ;
}
}
return tempnum ;
}
int main()
{
INT n ;
INT count ;
while( cin >> n && n )
{
count = 0 ;
count = enlerfun( n ) ;
cout << count << endl ;
}
return 0 ;
}
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std ;
#define INT __int64
int enlerfun( INT n )
{
int tempnum = n ;
for( int i = 2 ; i <= n ; ++i )
{
if( n % i == 0 )
{
tempnum -= tempnum / i ;
while( n % i == 0)
n /= i ;
}
}
return tempnum ;
}
int main()
{
INT n ;
INT count ;
while( cin >> n && n )
{
count = 0 ;
count = enlerfun( n ) ;
cout << count << endl ;
}
return 0 ;
}