Modulo A Prime Number
Modulo A Prime Number
We have seen that modular arithmetic can both be easier than normal arithmetic (in
how powers behave), and more difficult (in that we cant always divide).
But when n is a prime number, then modular arithmetic keeps many of the nice
properties we are used to with whole numbers.
(Recall that a prime number is a whole number, greater than or equal to 2, whose
only factors are 1 and itself. So 2, 3, 5, 7, 11 are prime numbers whilst, 6 = 2 3 and
35 = 5 7 arent.)
Inverses, Modulo a Prime
This, in fact, tells us more than Theorem 1; this tells us that when a 6= 0, then
dividing by a is the same as multiplying by an2, as
1
= an2 (mod n).
a
We now have an explicit expression for as multiplicative inverse.
Problems
1. Find 11 , 12 , 13 , 1
4 in mod 5 arithmetic.
2. Check, with n = 7 that Fermats Little Theorem holds for each value of a =
0, 1, 2, 3, 4, 5, 6 mod 7.
3. Which numbers is it valid to divide by in mod 9 arithmetic? For these numbers
find their inverses.
4. How many solutions has x2 + x = 0 in mod 6 arithmetic? (Try out each of the
numbers 0, 1, 2, 3, 4, 5 mod 6.)
5. Find two different ways to factorise x2 + x in mod 6 arithmetic.
Answers
A G M S Y 4
B H N T Z 5
C I O U 1 6
D J P V 2 7
E K Q W 3 8
F L R X 4 9
Another well-known codeis the ASCII code used in computing which assigns a number
between 0 and 255 to a wide array of symbols (upper and lower case alphabets,
punctuation marks, mathematical symbols etc.)
ISBN codes
The ISBN code (which stands fo International Standard Book Number is a 10-digit
number which appears on the back of every book published. For example, the ISBN
code of David Achesons 1089 and All That is
0198516231
It contains information about the language, publisher and title. The last digit of
the code is a check digit, which helps combat the problem that the code might be
miscommunicated.
A ISBN code abcdefghij is set up in such a way that
10a + 9b + 8c + 7d + 6e + 5f + 4g + 3h + 2i + j
is divisible by 11. The check digit j can be chosen in the range 0 6 j 6 10 so that
this is possible in the event that j = 10 then the letter X is used instead.
Turning Words into Numbers
The reason we need a code is that the RSA encryption, which we will meet later,
is based on clockwork arithmetic; we need to be able to convert any message into
numbers first, before we can apply modular arithmetic.
The following important features will be considered in creating any code:
There is a standard way in mathematics, called a Huffman code, for turning a message
into numbers, in a systematic and efficient way.
Example of a Huffman Code
Suppose we wish to send a message to a Martian Rover, which understands five
commands
uniquely decipherable. In fact, Huffman codes are more than this: they are
instantaneous. Not only can a coded message be uniquely deciphered, it can be
done so by reading the coded message number by number, without knowledge
of the whole code.
compact. This means that the average length of a Huffman-coded message is
the best possible using the numbers 0 and 1.
More general Huffman codes, using more than just the numbers 0 and 1, can be
easily made.
The Huffman code has no built in redundancy to deal with transmission errors.
Problems
1. Check that the ISBN code 0198516231 is a valid one.
2. I mistakenly wrote down the ISBN code of Codes and Cryptography as 0198532773,
but with one of the digits out by one. Show that this is an incorrect ISBN code.
Which numbers may have been wrong and what should they have been?
3. The following coded messages have all been made using the previous Huffman
code. Decode their command sequence.
010011101100, 011011101100, 01001100111100.
4. Write down a sequence of 0s and 1s which the Martian Rover couldnt interpret
as meaningful commands.
5. By grouping the Rovers commands differently, create a different Huffman code.
6. What is this average code length per command for your new code?
7. Find different decodings of the following Morse Code (with the gaps removed)
which do you think is the right one?
Answers
1. The ISBN code 0198516231 gives 0 + 9 + 72 + 56 + 30 + 5 + 24 + 6 + 6 + 1 =
209 = 19 11.
2. The ISBN code 0198532773 gives 0 + 9 + 72 + 56 + 30 + 15 + 8 + 21 + 14 + 3 =
228 = 8 (mod 11). So either the first 7 should have been an 8 (increasing this
sum by 3), or the 9 should have been an 8 (decreasing this sum by 8).
3. 010011101100 = North + West + East + South + Stop;
011011101100 = West + West + East + South + Stop;
01001100111100 = North + West + Stop + South + South + Stop.
4. Any odd length string of 0s would be meaningless to the rover.
5. Grouping first N & W, then E & S, then N+W & E+S, then all together, we
could get the Huffman code:
Stop = 0, North = 100, West = 101, East = 110, South = 111.
6. The new codes average length is 1/3 + 3/6 + 3/6 + 3/6 + 3/6 = 7/3 as before.
7. The piece of Morse code could be translated as HEEDRJ, SSBDO, or more
likely HELLO.