THE RULER TO RULE THEM ALL

To multiply two numbers, move the top ruler so the 1 on the top is aligned with the first factor on the bottom and read the number under the other factor's notch on the top ruler.

For example, to multiply 3x4, move the top ruler so the 1 on top aligns with the 3 on the bottom and read the number under the 4 on the top ruler, which should be 12. (swapping the factors doesn't affect the result)

If the product is equal or greater than N, the answer won't be the product of the two numbers. This is because the answer actually is the product modulo N, so higher values of N allow for bigger products at the cost of a bigger ruler, which is harder to use.

Source code available at Github - Back to my main page




The ruler can also divide if you move the top ruler so the divisor on top aligns with the 1 on the bottom and then look at the dividend on top and the number it's got under is the quotient (if the division is possible).

The numbers on the rulers are actually the powers of g modulo N. Because of modular arithmetic, multiplication and addition work well before and after applying the modulo N.

When g and N are coprime, the powers of g modulo N are periodic. Once you get a power that is congruent with one, all the powers above it are repeated.

However, those powers don't always cover all the numbers between 1 and N. When this does happen, g is refered to as a primitive power modulo N and the ruler can be used.