Identity Function
Time limit5sMemory limit512 MB
Given N, find the smallest positive k with every iterate F_k(a)=a for 1<=a<N under f(a)=a^N mod N, or output -1.
- Level
Hard8 of 10
- Topics
- Math, Number theory, Recursion
- Solved
- No attempts yet
Problem
You are given an integer , which is greater than .
Consider the following functions:
- ()
Here denotes the integer modulo operation. For a non-negative integer and a positive integer , is the remainder of divided by .
Output the minimum positive integer such that for all positive integers less than . If no such exists, output .
Input
The input consists of a single line that contains an integer (), whose meaning is described in the problem statement.
Output
Output the minimum positive integer such that for all positive integers less than , or if no such exists.