Hacking Secret Ciphers with Python

(Ann) #1
Chapter 14 – Modular Arithmetic and the Multiplicative Cipher 201

Above are some rectangular blocks with a width of 1 unit, 2 units, 3 units, and so on. The block’s
length can be used to represent a number. You can count the number of squares in each block to
determine the length and number. These blocks (sometimes called Cuisenaire rods) can be used to
visualize math operations, like 3 + 2 = 5 or 5 × 3 = 15 :


Figure 14 - 3. Using Cuisenaire rods to demonstrate addition and multiplication.

If we represent the number 30 as a block that is 30 units long, a number is a factor of 30 if the
number’s blocks can evenly fit with the 30-block. You can see that 3 and 10 are factors of 30:


Figure 14- 4. Cuisenaire rods demonstrating factors.

But 4 and 7 are not factors of 30, because the 4-blocks and 7-blocks won’t evenly fit into the 30-
block:


Figure 14- 5. Cuisenaire rods demonstrating numbers that are not factors of 30.

The Greatest Common Divisor of two blocks (that is, two numbers represented by those blocks)
is the longest block that can evenly fit both blocks.

Free download pdf