The divisor p should be as small as possible in order to minimize the length of the table. We can thus rule out zero as a remainder value, so the divisor must be at least one more than the word length. This bound is in fact achieved for some word lengths. Now p does not divide 2 because p is odd, so p must divide 2 -1. We now consider even p.
Execution is quite speedy.
The maximum value of Ord 2 is given by p Euler's phi-function, sometimes called the totient. If p is not prime, the totient is smaller.