SETMOD INDEX

SETMOD _ _ _ _ _ _ _ _ _ _ _ _ command

The setmod command sets the modulus value for subsequent modular arithmetic.

syntax:

setmod<integer>

<integer> must be positive, and greater than 1. It need not be a prime number.

examples:


setmod 6; 

  1 


on modular; 

16; 

  4 


x^2 + 5x + 7; 

   2
  X  + 5*X + 1 


x/3; 

  X
  - 
  3


setmod 2; 

  6 


(x+1)^4; 

   4
  X  + 1 


x/3; 

  X

setmodreturns the previous modulus, or 1 if none has been set before. setmod only has effect when modular is on.

Modular operations are done only on numbers such as coefficients of polynomials, not on the exponents. The modulus need not be prime. Attempts to divide by a power of the modulus produces an error message, since th e operation is equivalent to dividing by 0. However, dividing by a factor of a non-prime modulus does not produce an error message.