Solving for $x$ where $p^x \equiv 1 \pmod {q\#}$ For a given primorial $q\#$, you can generate a subset of the reduced residue system by using the power of a prime $p$ where $p > q$.
For example, for $5\#$, we can use the powers of $7$ to generate $4$ of the elements of the reduced residue system:


*

*$7^1 \equiv 7 \pmod {30}$

*$7^2 \equiv 19 \pmod {30}$

*$7^3 \equiv 13 \pmod {30}$

*$7^4 \equiv 1 \pmod {30}$


The count of these elements is the solution for $x$ where:
$$p^x \equiv 1 \pmod {q\#}$$
As I understand it, $p^x$ forms a subgroup so it follows that if $q$ is the $n$th prime $p_n$, then by Lagrange's Theorem:
$$x\, | \prod_{i=1}^{n}{p_i - 1}$$
Since $q\# - p^i$ is also an element of the reduced residue system that is distinct from $p^i$, my assumption is that:
$$x\, | \prod_{i=2}^{n}{p_i-1}$$
So, my assumption is that if $x$ is the least postive integer where $p^x \equiv 1 \pmod {q\#}$, then:
$$\prod_{i=2}^{n}{p_i-1}\ge{x}>\log_{p}q\#$$ 
Other than brute force, is there a standard way to solve for $x$?  Is there any other properties that are known about $x$?  Are all of my assumptions about $x$ correct?
 A: I think that what you are asking is a special case of the discrete log problem. No efficient algorithm is known for this problem, and it is conjectured that none exists.
http://en.m.wikipedia.org/wiki/Discrete_logarithm
However, in this case, since q# is a primorial, perhaps you can do better.
The Chinese remainder theorem implies that $p^x=1$ mod $q\#$ if and only if $p^x = 1$ mod all of the primes that are at most $q$. For example, if $q=11$ and $p=13$, computing the order of 13 mod $q\# = 2310$ directly seems a daunting task, but all we have to do is note that $13=1$ mod $ 2$ and $3$, $13=3$ mod $5$, $13=6 (=-1)$ mod $7$, and $13=2$ mod $ 11$. The order of three mod 5 is 4, the order of 2 mod 11 is 10, and the order of six mod 7 is 2. The least common multiple of $1,1,4,2,10$ is 20, so 20 is the least number such that $13^{20}=1$ modulo all of the primes up to 11, so $13^{20}=1$ modulo $11\#$, again by the Chinese remainder theorem.
To summarize, all you have to do is find the orders of $p$ modulo the primes that are at most $q$, and then take the least common multiple of these orders.
