Order of Element in Z_{n}

Hi All,

Is there an easy (or computationally inexpensive) way of determining
the order of an element in Z_{n}?

So far, I've been perfoming test exponentiations to determine the
order. I've played tricks such as using elements with low hamming
weights. For example, N=1924177, element=2 (hamming weight of 1). The
order of 2 is 5796. Below, there are other tricks I can play with
variable i so it is not a linear search.


for( i = 2; i < N; i++ )
if( 2^i mod N == 1)
found = true;