poj2407-Relatives

http://poj.org/problem?id=2407

欧拉函数

 

#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 ;
}


 

 

posted @ 2013-06-07 20:10  爱生活,爱编程  阅读(145)  评论(0)    收藏  举报