def is_primitive_root(r, p, factors, exponents):
 if (p != (prod(factors, exponents) + 1)):
  return False
 for f in factors:
  (q, control) = divmod((p - 1), f)
  if (control != 0):
   return False
  if (pow(r, q, p) == 1):
   return False
 return True

def is_primitive_root ( r , p , factors , exponents ) : if ( p != ( prod ( factors , exponents ) + 1 ) ) : return False for f in factors : ( q , control ) = divmod ( ( p - 1 ) , f ) if ( control != 0 ) : return False if ( pow ( r , q , p ) == 1 ) : return False return True
returns true if a is a primitive root of p a is said to be the primitive root of p if gcd == 1 and totient(p) is the smallest positive number s .