# include <stdio.h>
# include <string.h>
int phi[100000] ;
int main()
{
int i,j;
memset ( phi , 0 ,sizeof ( phi ) ) ;
phi[1]=1;
for ( i = 2 ; i <= 10000 ; i ++ )
{//筛选求phi
if ( ! phi [i] )
{
for ( j = i ; j <= 10000 ; j += i )
{
if ( ! phi [j] )
phi [j ] = j ;
phi [j] = phi [j] / i * ( i - 1 ) ;
}
}
}
int n;
while(~scanf("%d",&n)&&n)
{
printf("%d\n",phi[n]);
}
return 0;
}
筛选欧拉数n
最新推荐文章于 2022-10-06 16:42:14 发布