11.Uebung, Mathematik 3, CMS, 20.12.2005

11.2

<< Algebra`PolynomialPowerMod`

    
Deg[f_, var_] := 
        Length[CoefficientList[f, var]] - 1;

    
PrimitiveQ[w_, f_, var_, 
          p_] := 

 (* 
          returns True if the element w from the field
Z_p[var]/f is primitive,  
          returns False otherwise *) 

Module[{size, factors, n, i, 
            canStillBePrimitive, r}, 
size = 
            p^Deg[f, var]; 
factors = 
            FactorInteger[size - 1]; 
n = 
            Length[factors]; 
i = 
            1; 
canStillBePrimitive = 
            True; 
While[
            canStillBePrimitive  && 
              i <= n, 
r = (size - 
                    1)/factors[[i]][[1]]; 
canStillBePrimitive =


]; 
canStillBePrimitive];

11.3

RandomPoly[var_, degree_, p_] := 
      Sum[Random[Integer, {0, p - 1}] var^i, {i, 0, degree}]