2%1 == 1

or

(3^2)%2 == 1

In addition, modulus is really easy to figure out without a calculator. Simply subtract the modulus number until the reult is less than the modulus operator. This method seems a little easier than the one posted a few comments above by James. A few examples:

9%2 = 1

–

9-2 = 7 (7 < 2) { false }

7-2 = 5 (5 < 2) { false }

5-2 = 3 (3 < 2) { false }

3-2 = 1 (1 < 2) { true }

5%3 = 2

—

5-3 = 2 (2 < 3) { true }

7%2 = 1

—

7-2 = 5

5-2 = 3

3-2 = 1

19%4 = 3

—

19-4 = 15

15-4 = 11

11-4 = 7

7-4 = 3

For a negative number, I imagine you can just drop the negative operator (work on it’s absolute value).

]]>I find numbers fascinating. Prime numbers, Fibonacci sequence, Caesar cipher (simple shift cipher) and things alike. Cryptography plays an important role in technology security (online, offline and basically everywhere). Modulo aritchmetic is used in public key cryptography: RSA. Of course there’s much more to cryptography than just modulo arithmetic.

I’d like to thank James for his non-calculator solution since it nicely shows how it works. I always use a simple example to explain how it works. Take 3^2(mod)2 for example.

3^2(mod)2 = 9(mod)2

2 * 4 = 8 (2 fits 4 times in 9)

9 – 8 = 1 (which is the remainder)

therefore: 3^2(mod)2 = 1

I think this should be enough mathematics for a whole year. Back to important things! Back to design and interfaces!

]]>For a non-calculator solution (if anyone’s interested),

If a (mod x) = b (mod x)

and c (mod x) = d (mod x),

then a*c (mod x) = b*d (mod x).

Note also that negatives are permissible in modulo arithmetic, and any numbers with the same remainder in the corresponding base are equal (congruent). In other words,

54 (mod 65) = -11 (mod 65).

Continuing (all in mod 65),

54^2 = (-11)^2 = 121 = -9

54^4 = 54^2 * 54^2 = -9 * -9 = 81 = 16

54^6 = 54^4 * 54^2 = 16 * -9 = -144 = -14

54^7 = -14*-11 = 154 = 24

Therefore, DH is 24.

]]>Anyway, just wondering if there is a easy equation to find how anyones age would be respresented like that. I’m looking for a way to give my age (or anyones) and have it spit out the equation representing that age.

]]>Although you were all able to perform the calculation you didn’t provide me with a satisfactory rationale. I was expecting the calculation itself to be solved rather quickly.

However I need an explanation of how modulo (mod) works and not just a description of the formula. Include a simple example along with a summary in words of how it is actually being calculated and the $20 is yours! But don’t forget to post it on SkinnyJ.

]]>the ^ means the first raised to the power of second

mod means the remainder when the first is divided by the second

]]>1338925209984 mod 65 = 24

]]>