Euler's Problem
Time limit1sMemory limit128 MB
Given n, list every x with Euler phi(x) equal to n in increasing order, or report none.
- Level
Hard8 of 10
- Topics
- Number theory, Backtracking, Recursion
- Solved
- No attempts yet
Problem
Leonhard Euler (1707-1783) was a great mathematician. This problem uses one of the functions named after him, the Euler function.
For a natural number , the value of at is the count of numbers () that are coprime to . Two numbers are coprime when they have no common divisor greater than . For example , because and are coprime to while , , and are not.
Had Euler lived on, he might have posed this: for a given natural number , find every natural number that satisfies .
Input
The first line contains one natural number (), the number of data sets. Each of the next lines describes one data set and holds a single natural number ().
Output
Print the answers for the data sets in the order they appear in the input. The answer for one data set takes two lines. The first line holds the number of solutions. The second line holds every solution of the equation in increasing order. When the equation has no solution, leave the second line of that data set's answer empty.