Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #define MAX_SHORT_VALUE 32767 /* 2^15 - 1 */
- int Phi(int i)
- {
- if (i==1) return 1;
- int res = i;
- if (i%2==0)
- {
- res -= res/2;
- do {i/=2;}
- while (i%2==0);
- }
- for (int j = 3; j*j <= i; j += 2)
- if (i%j==0)
- {
- res-=res/j;
- do i/=j;
- while (i%j==0);
- }
- if (i>1) res-=res/i;
- return res;
- }
- int main()
- {
- std::vector<int> result_numbers;
- int n;
- std::cin>>n;
- for( short x = 1; x < MAX_SHORT_VALUE; x++ )
- if( Phi(x) == n )
- result_numbers.push_back(x);
- for(auto x: result_numbers)
- std::cout << x << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement