Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int phi(int n)
- {
- int result=n;
- for(int i=2;i*i<=n;i++){
- if(n%i==0){
- while(n%i==0)
- n/=i;
- result-=(result/i);
- }
- }
- if(n>1)
- result-=(result/n);
- return result;
- }
- int main()
- {
- int i;
- while(1){
- cin>>i;
- cout<<"Value of phi("<<i<<") : "<<phi(i)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement