I have an exercise about cyclic number but I haven't found the solution yet. Can you help me on it.
This is the problem.
Print out the maximum value of number base b (1 < b < x) so that there exists a positive cyclic number of length n under base b. Note that leading-zeroes are allowed.
Input: two integers n and x (1 <= n <= 5*10^6, 2 <= x <= 10^9)
Output: print a single integer - the largest b that exists. If no such b exists, print -1.

Thanks in advance!