HEU 1008 Relatives

 1 /**************************************
 2Problem HEU 1008 Relatives
 3Time 0.0080s
 4Memory 236 k 
 5Accepted Time 2009-03-21 21:28:24
 6Tips 欧拉函数 http://acm.hrbeu.edu.cn/forums/index.php?showtopic=2181&hl=1008 
 7**************************************/

 8 #include  < stdio.h >
 9 int  main()
10 {
11    long n,i;
12    while(scanf("%ld",&n),n!=0)
13    {
14        long sum=1;
15        for(i=2;;i++)
16        {
17            if(n%i==0)
18            {
19                sum*=i-1;
20                n/=i;
21                while(n%i==0)
22                {
23                    n/=i;
24                    sum*=i;
25                }

26            }

27            if(n==1)break;
28        }

29        printf("%ld\n",sum);
30    }

31    return 0;
32}

33

你可能感兴趣的:(relative)