Computer Science Canada

Mod Help!

Author:  aqazwsx1 [ Wed Jan 28, 2009 5:20 pm ]
Post subject:  Mod Help!

Hi, I was wonder how the mod function works? Why does 2 mod 7 =2? Thanks! Very Happy

Author:  saltpro15 [ Wed Jan 28, 2009 5:24 pm ]
Post subject:  RE:Mod Help!

the mod is the remainder left over after the numbers are divided

Author:  jbking [ Wed Jan 28, 2009 5:29 pm ]
Post subject:  RE:Mod Help!

Mod is simply the remainder when a division is done. Another way to think about this is the following if you want a more technical interpretation:

a mod b = x where x+bk = a for some integer k.

Note, that x doesn't have to be between 0 and b-1 though this is usually how it is expressed.

Author:  aqazwsx1 [ Wed Jan 28, 2009 5:36 pm ]
Post subject:  Re: Mod Help!

doesn't 2 mod 7 = 6 ? Why is it 2 ?

Author:  Tony [ Wed Jan 28, 2009 5:44 pm ]
Post subject:  RE:Mod Help!

how do you figure it to be 6?

Author:  aqazwsx1 [ Wed Jan 28, 2009 5:48 pm ]
Post subject:  Re: Mod Help!

2/7 so , you add a "0. " so you make the 2 into a 20 , then you find 7*2=14 , so 20-14=6

Author:  jbking [ Wed Jan 28, 2009 5:55 pm ]
Post subject:  Re: Mod Help!

aqazwsx1 @ Wed Jan 28, 2009 3:36 pm wrote:
doesn't 2 mod 7 = 6 ? Why is it 2 ?


No, but 2 mod 7 = 9, since 7+2=9 which means that for k=1 the expression 7k+2 evaluates to 9, in case you were looking at the number upside down.

This presumes that you understand some basics on division, which can be structured in the following way:
a divided by b gives a quotient of c and a remainder of d satisfies the following equation:

b*c+d = a

Thus, if we take 2 and divide it by 7, there is a quotient of 0 and a remainder of 2, not 6.

Author:  aqazwsx1 [ Wed Jan 28, 2009 6:15 pm ]
Post subject:  Re: Mod Help!

ok thanks


: