Follows 10179.c (Total 42 lines):

/* @JUDGE_ID:4461XX 10179 C */
/* A */
#include<stdio.h>
#include<math.h>

int n ;

int result( void )
{
	int before=1 , i , sqrtN , ans=n ;

	sqrtN = (int)sqrt( (double)n ) ;
	for( i=2 ; i<=sqrtN&&n!=1 ; )
		if( !( n%i ) ){
			if( i!=before ){
				ans /= i ;
				ans *= i-1 ;

				before = i ;
			}

			n /= i ;
		}
		else ++i ;

	if( n!=1 ){
		ans /= n ;
		ans *= n-1 ;
	}

	return ans ;
}
int main( void )
{
	while( scanf( "%d" , &n )==1 ){
		if( !n ) break ;

		printf( "%d\n" , result() ) ;
	}

	return 0 ;
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com