Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- Bismillahir Rahmanir Rahim
- _______
- | __ \ _____
- | |__| )_______ | / ____ ______
- | ____/ \__ \ | |__ / \ | \
- | ( / __ \ | __ \ / __ \ | /\ \
- | | (____ / | / \ / |__/ \ )
- |__| \/ |____/ \____/ \/
- ***/
- #include<bits/stdc++.h>
- using namespace std;
- int phi(int n)
- {
- int ret = n,i;
- for(i=2 ; i*i<=n ; i++)
- {
- if(n%i==0)
- {
- while(n%i==0)
- {
- n/=i;
- }
- ret-=ret/i;
- }
- }
- if(n>1)
- {
- ret-=ret/n;
- }
- return ret;
- }
- int main()
- {
- int n;
- while(cin>>n)
- {
- cout<<phi(n)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment