# Math Help - Modulo

1. ## Modulo

Hi all,
How would you calculate (3+15)mod7 or (6^4)mod7?
I don't know anything about modulo. I read an article about it on Wikipedia, but there doesn't seem to be an example which fits the question I have above.

Thanks for the help!

2. To perform an operation modulo n, simply perform the operation as you would normally do, then divide it by n. The result you want is the remainder of the division. For example, 3 plus 15 modulo 7 is equivalent to 4 (3 + 15 = 18, 18 when divided by 7 gives a remainder of 4).
Hope that helps!

3. So if I have understood this correctly, (6^4)mod7 would be (1296)mod7 which would be 1?

4. You betcha!

5. Stapel I hope you realise that you are my hero lol

Edit: Oo just one more thing: (5-8)mod6 = -9? Would that be correct? I'm just unsure because it is negative.

6. Five less eight is minus three. When you're working "mod six", you repeat every six:

Code:
... 0  1  2  3  4  5  0  1  2  3  4  5  0  1  2  3...
...-6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7  8  9...
What corresponds to -3?

7. I'm confused. The answer is either -3 or 6, but I'm unsure which one...

8. If you are in "mod 6", then every integer corresponds to 0, 1, 2, 3, 4 or 5 (note that it cannot result in a negative integer). A table, such as stapel's, allows you to quickly convert any integer (positive or negative) into its "mod 6 version". Check the lower line for your number, in this case -3. It corresponds to what number? 3.

9. I see, so 3 is the answer...but when I type -3mod6 into a calculator it returns an answer of -3. Why is this?

Using http://www.math.uga.edu/~bjones/calc/ it returns an answer of 1...

This is why I am confused lol

10. Most likely, when you input -3mod6 the calculator performs -(3mod6) rather than (-3)mod6. And if you look at the help section of the calculator in the link your provided, it says: "This calculator is not smart enough to handle negative numbers."

11. Originally Posted by mathsguy
So if I have understood this correctly, (6^4)mod7 would be (1296)mod7 which would be 1?

Just FYI you can simpily cacluations breaking it up into factors

Note that

$6^4=2^4\cdot 3^4 = 8\cdot 2 \cdot 9 \cdot 9$

We can reduce each of these factors mod 7 to get

$8\cdot 2 \cdot 9 \cdot 9 \mod (7) = 1\cdot 2 \cdot 2 \cdot 2 \mod(7) =8 \mod(7)=1\mod(7)$

12. Just a little more formal treatment.

Two integers a and b are said to be congruent modulo n if and only if $n|(a-b)$. That is n divides the difference between the two numbers. That means there is an integer k such that $nk=a-b$.

With this you can see the integers are partitioned into n equivalence classes. In particular, multiplication is well defined (a similar argument shows addition is also well defined).

(ab) mod n = (a mod n) (b mod n) That is it doesnt matter if you reduce modulo n first before you multiply.
$(a + nk)(b+ nl)=ab + nal + nbk + n^2kl = ab + n(al + bk + nkl)$
but certainly $n|ab - ab + n(al + bk + nkl)= n(al + bk + nkl)$.

$(a + nk)+ (b +nl) = (a+b) + n(k+l)$
$n|(a+ b) - (a+b) + n(k+l) = n(k+l)$

In particular, this puts $\emptyset$'s attack on firm foundation and in general greatly reduces computations.