A game with primes
All submissions for this problem are available.
Prithvi , An AI machine which likes playing with prime numbers. A prime number is given to prithvi , He has to calculate the primitive numbers of the given prime number. A number X is primitive of a prime number P, if (X^i) mod P generates all numbers in range 1 to P-1 where i ranges from 1 to P-1. Due to government’s erratic power cut operations, prithvi has malfunctioned and failed to execute its job. So , your task is to find the primitive numbers of the given prime number.
Note: Input given will be a prime number.. Return 0 if there are no primitive numbers for a prime number.
First line contains the number of prime numbers N.
Following N lines have prime number P.
For each test case, output the primitive numbers of the prime number .
Input: 2 5 13 Output: 2 3 2 6 7 11
|Time Limit:||3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.