/*
2 ^ x mod n = 1
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 11800 accepted submission (s): 3673
Problem description
Give a number N, find the minimum x (x> 0) that satisfies 2 ^ x mod n = 1.
Input
One positive integer on each line, the value of N.
Output
If the minimum x exists, print a line with 2 ^ x mod n = 1.
Print 2 ^? MOD n = 1 otherwise.
You shoshould replace X and N with specific numbers.
Sample Input
2
5
Sample output
2 ^? MoD 2 = 1
2 ^ 4 mod 5 = 1
*/
# Include <stdio. h>
Int main (){
Int I, j, N, S;
While (~ Scanf ("% d", & N )){
If (n = 1 | n % 2 = 0) printf ("2 ^? MoD % d = 1 \ n ", N );
Else {
_ Int64 S = 1;
Int I;
For (I = 1; I ++ ){
S * = 2;
S % = N; // The value of controlling S is within a certain range, and N is obtained after multiplying 2.
If (S = 1) {// If (S % N = 1)
Break;
}
}
Printf ("2 ^ % d mod % d = 1 \ n", I, n );
}
}
Return 0;
}