 in practice, we try
in practice, we try  , then
, then  , etc., until we find an
, etc., until we find an  that has order
that has order  .  Computing the order of an element of
.  Computing the order of an element of 
 requires factoring
requires factoring  , which we do not know how to do quickly in
general, so finding a primitive root modulo
, which we do not know how to do quickly in
general, so finding a primitive root modulo  for large
 for large  seems to 
be a difficult problem.
 seems to 
be a difficult problem.
 this algorithm computes the smallest positive
integer
 this algorithm computes the smallest positive
integer  that generates
 that generates 
 .
.
 ?] If
?] If  output
 output  and terminate.  
Otherwise set
 and terminate.  
Otherwise set  .
.
 of
 
of  .
.
 , we have
, we have 
 ,
then
,
then  is a generator of
 is a generator of 
 , so output
, so output  and terminate.
 and terminate.
 and go to step 3.
 and go to step 3.
 .
The order of
.
The order of  is a divisor
 is a divisor  of 
the order
 of 
the order  of the group
 of the group 
 .   
Write
.   
Write 
 , for some divisor
, for some divisor  of
 of  .
If
.
If  is not a generator of
 is not a generator of 
 , then
since
, then
since 
 ,  there is a prime divisor
,  there is a prime divisor 
 of
 of  such that
 such that  .
Then
.
Then 
 
Conversely, if
 is a generator, then
 is a generator, then 
 for any
for any  .  Thus the algorithm terminates with step 3
if and only if the
.  Thus the algorithm terminates with step 3
if and only if the  under consideration is a primitive root.
By Theorem 2.5.8 there is at least one primitive
root, so the algorithm terminates.
 under consideration is a primitive root.
By Theorem 2.5.8 there is at least one primitive
root, so the algorithm terminates. 
  
William 2007-06-01