Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

## #1 2012-10-12 19:51:12

Harold
Guest

### Modulo

Can you help me with these two problem
-23 mod 5
23 mod -5
and,could you please explain modulo with nagetive number?

## #2 2012-10-12 20:20:23

bobbym

Online

### Re: Modulo

Hi;

If you use this formula you will have no problems with modulo.

Where

is called the floor function and is evaluated like this:

and

it always rounds down to the smallest integer.

Let's do the first one:

-23 mod 5

You are looking for r, the remainder. a = -23 and m is the modulo, in this case 5.

Now

So -23 mod 5 is 2.

You try the second one. Let me know what you get.

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #3 2012-10-12 21:56:51

Harold
Guest

### Re: Modulo

It is -2,is nagetive number allowed as result?

## #4 2012-10-12 22:21:10

bobbym

Online

### Re: Modulo

Hi;

Yes, unless you are told it must be positive.

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #5 2012-10-12 22:30:24

Harold
Guest

### Re: Modulo

Thank you^infinity

## #6 2012-10-12 23:07:52

bobbym

Online

### Re: Modulo

Hi;

You are welcome. Were you able to do the second problem?

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #7 2012-10-12 23:50:15

bob bundy
Moderator

Offline

### Re: Modulo

hi bobbym,

Yes he has (in post 3).  He got -2

The definition for modulo regarding + or - is uncertain.  See http://en.wikipedia.org/wiki/Modulo_operation

Harold ought to check how it has been defined by his teacher.

Bob

You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei

## #8 2012-10-13 00:10:13

bobbym

Online

### Re: Modulo

Hi;

Yes he has (in post 3).  He got -2

I see that now. He got the right answer too.

Sometimes it has to be the same sign as the divisor. I gave him the one that gets the same answers as Wolfram would.

Unfortunately he skeddadled right after he solved it. I wanted to go a little deeper.

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #9 2012-10-13 02:21:18

Harold
Guest

### Re: Modulo

Guys,I have another problem,my brother says that 23 mod -5 will be 3 as Euclidean division states a=bq+r and the division will be 23=(-5)*(-4)+3.

## #10 2012-10-13 03:15:27

bob bundy
Moderator

Offline

### Re: Modulo

hi Harold,

In effect, that was my point in post 7.

The following are all equivalent mod 5

-12,  -7,  -2, 3, 8, 13, 18 ......

Basically just add 5.

If you follow my link to Wiki you will see that two definitions are possible and there are even more variations amongst computer languages.

Your brother is right using the 'Euclidean division' definition ... under this no negatives are allowed.

Which is why I think you need to check with your teacher / tutor and see what definition is required.

Bob

You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei

## #11 2012-10-13 19:30:24

Harold
Guest

### Re: Modulo

I am sorry to bug again but after you gave me the formula,i experimented a little and solution to -23 mod -5 results -43,is it correct

## #12 2012-10-13 20:24:25

bobbym

Online

### Re: Modulo

Hi;

I am getting -3 as the answer. Can I see what you have done?

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #13 2012-10-13 20:47:16

bob bundy
Moderator

Offline

### Re: Modulo

Looks like -23 - 20 = -43 rather than -23 + 20 = -3

There are a lot of minus signs to take account of.  Easy to slip up on that.

Bob

You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei

## #14 2012-10-13 21:00:24

bobbym

Online

### Re: Modulo

Hi;

I am getting

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #15 2012-10-13 22:43:55

Harold
Guest

### Re: Modulo

You're right,i missed a minus sign,thank you a lot,you guys taught me a lot of things today.

## #16 2012-10-13 22:49:15

bobbym

Online

### Re: Modulo

Hi Harold;

Use a calculator to at least check.

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #17 2012-10-14 18:51:07

bob bundy
Moderator

Offline

### Re: Modulo

The formula should always give a value x, so that -m < x < m (assuming m is positive ... reverse the signs otherwise)

Bob

You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei

## #18 2012-10-14 20:37:55

bobbym

Online

### Re: Modulo

Hi bob;

If you did that what do you get for -65 mod -17?

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #19 2012-10-14 20:57:00

bob bundy
Moderator

Offline

### Re: Modulo

Good morning bobbym

Bob

You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei

## #20 2012-10-14 21:02:32

bobbym

Online

### Re: Modulo

Hi Bob;

Good Morning.

That is what I am getting too.

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.

## #21 2012-10-14 21:08:00

bob bundy
Moderator

Offline

### Re: Modulo

My point was that Harold can eliminate obvious errors such as -43 on the grounds that it is out of range.

Bob

You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei

## #22 2012-10-14 21:11:05

bobbym

Online

### Re: Modulo

Hi;

Yes, it is an obvious error, the answer can never exceed m. In either direction.

In mathematics, you don't understand things. You just get used to them.
Probability is the most important concept in modern science, especially as nobody has the slightest notion what it means.
90% of mathematicians do not understand 90% of currently published mathematics.