Problem Statement | |||||||||||||
Let p be a prime number. Zp is a set of numbers from 1 to (p - 1), inclusive. An element a of Zp is a generator of Zp if the set {1, a%p, (a*a)%p, (a*a*a)%p, ..., (a^(p-2))%p} is equal to Zp (here '%' represents the modulus operator).
You will be given a prime p. Write a method that returns a int[], containing all generators of Zp that are less than p in ascending order. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | For all a and b, (a * b) % p is equal to ((a % p) * (b % p)) % p. | ||||||||||||
Constraints | |||||||||||||
- | p is a prime between 3 and 1000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|