immuntasir

Phi

Aug 4th, 2015
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. #include <stdio.h>
  2. int gcd(int a,int b){
  3. if(a%b==0) return b;
  4. else gcd(b,a%b);
  5. }
  6.  
  7. int main(){
  8. int n,i,count=0;
  9. scanf("%d",&n);
  10.  
  11. for(i=1;i<=n;i++){
  12. if(gcd(i,n)==1) count++;
  13. }
  14. printf("Phi(%d ) = %d\n",n, count);
  15.  
  16. return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment