You are not logged in.
Can you help me with these two problem
-23 mod 5
23 mod -5
and,could you please explain modulo with nagetive number?
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
It is -2,is nagetive number allowed as result?
Hi;
Yes, unless you are told it must be positive.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Thank you^infinity
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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.
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
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
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
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
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
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
Hi;
I am getting
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
You're right,i missed a minus sign,thank you a lot,you guys taught me a lot of things today.
Hi Harold;
Use a calculator to at least check.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Am I right about this:
The formula should always give a value x, so that -m < x < m (assuming m is positive ... reverse the signs otherwise)
Bob
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Good morning bobbym
Bob
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
Hi Bob;
Good Morning.
That is what I am getting too.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
My point was that Harold can eliminate obvious errors such as -43 on the grounds that it is out of range.
Bob
Children are not defined by school ...........The Fonz
You cannot teach a man anything; you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you! …………….Bob
Offline
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.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline