06.01.2015 Views

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

Cryptology - Unofficial St. Mary's College of California Web Site

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.1. THE REMAINDER OPERATOR 35<br />

Performing the %26 operation is not particularly difficult, but what if the<br />

number we are trying to reduce is 48924 Then repeatedly subtracting 26 is<br />

rather unappealing. Fortunately, we are not interested in the number <strong>of</strong> times<br />

we subtract 26, but rather in the number that is remaining when we are done.<br />

Just as multiplication is addition done quickly (4 × 3 just means 4 sets <strong>of</strong> 3, or<br />

3 added to itself 4 times), subtracting 26 many times is very closely connected<br />

to dividing by 26.<br />

To illustrate, we divide 85 by 26 using the form we learned as children:<br />

3 r = 7<br />

26 √ 85<br />

78<br />

7<br />

In multiplicative form this says 85 = 3 × 26 + 7. The 3 represents the quotient,<br />

how many times 26 goes into 85, and 7 is the remainder. Compare this with<br />

the subtraction method. 85%26 = Subtracting once: 85 − 26 = 59, and 59<br />

is larger than 26. Subtracting again: 59 − 26 = 33, still too large. Once more<br />

33 − 26 = 7. Small enough. So 85%26 = 7. Notice that the quotient 3 is the<br />

same as the number <strong>of</strong> subtractions, and that the remainder 7 is the same as<br />

the modulus answer.<br />

Let us try again with 109%26.<br />

4 r = 5<br />

26 √ 109<br />

104<br />

5<br />

so 109 = 4 × 26 + 5. On the other hand,<br />

109 − 26 = 83<br />

83 − 26 = 57<br />

57 − 26 = 31<br />

31 − 26 = 5.<br />

So 109%26 = 5. Again the quotient indicates how many 26’s need to be removed,<br />

and the remainder in the division gives the same result as the remainder<br />

operator.<br />

For numbers larger than about fifty the division method is generally quicker

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!