Go Dorchadas!

Date: 2013-Oct-19, Saturday 01:15 (UTC)
Hey,

First, I want to say congrats on making a first foray into computer programming!

Second, as far as the -2 mod 5 = 3 thing. That stems, I believe, from a particular element of math I remember from university. Basically if you are working with a certain range of numbers, say 0, 1, 2, 3, 4, then you can define addition operations using those with a modulo of the size of your range. You always have to get back a value in that range. Thus "4+1=0" because it goes beyond your range and wraps around. i.e. (4+1) mod 5 = 0.

When you're working with those, then -2 is "the same as" or technically speaking "congruent to" 3. You can never get back a negative number from a modulo operation. You *have* to get back one of your numbers in the range 0-4.

("Congruent to": two numbers are congruent to each other if you take their difference and the result is evenly divisible by whatever you're using for mod. 3 - (-2) mod 5 = 5 mod 5 = 0, so they are congruent to each other.)

http://mathworld.wolfram.com/Congruence.html
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting