# Math Help - How do I calculate modulo?

1. ## How do I calculate modulo?

If I wanted to convert a list of numbers: 1, 4, 17, 29, 64, 1293 into modulo 3, modulo 5, and modulo 9.. How would I do that? I had never heard of modulo up until this point (except in programing, but even then I had never heard of different types of modulo)

2. ## Re: How do I calculate modulo?

I'm not sure what you are asking for exactly... do you want to find 1 modulo 3, 4 modulo 3, etc and then with 5 and and so on?

Or find a certain number modulo 3 = 1?

If it's the former,
1 % 3 = 1
(the remainder when 1 is divided by 3 is 1)
4 % 3 = 1
17 % 3 = 2

As for the latter, you have the first one.
to get 4, you need a number greater than 3, 5 is just what is needed.
9 % 5 = 4

% means modulo in programming

3. ## Re: How do I calculate modulo?

The modulo (as I learned it) is defined as 'the remainder after floored division of a number X by another number Y'.

In mathematical form this is:
$\text{mod}(X,Y)=X-\text{floor}(\frac{X}{Y})\cdot Y$
in which 'floor' means round to the nearest integer in negative infinity direction.

So let's pick one of your examples. You're saying that you want to convert a list of numbers into modulo 3. In this case X would be the number from your list, and Y would be 3.

4. ## Re: How do I calculate modulo?

Originally Posted by corsica
The modulo (as I learned it) is defined as 'the remainder after floored division of a number X by another number Y'.

In mathematical form this is:
$\text{mod}(X,Y)=X-\text{floor}(\frac{X}{Y})\cdot Y$
in which 'floor' means round to the nearest integer in negative infinity direction.

So let's pick one of your examples. You're saying that you want to convert a list of numbers into modulo 3. In this case X would be the number from your list, and Y would be 3.
Sorry... confused!

5. ## Re: How do I calculate modulo?

Take 3 % 5.

mod(3, 5) = 3 - floor(3/5)5

3/5 = 0.6 => 0

0*5 = 0

3 - 0 = 3

so 3 % 5 = 3

(Or the remainder when 3 is divided by 5 is 3)

6. ## Re: How do I calculate modulo?

Originally Posted by Also sprach Zarathustra
Sorry... confused!

7. ## Re: How do I calculate modulo?

Maybe it also helps to have a real-world example. Suppose you're navigating a ship with a compass. The compass bearing (the direction in which you're sailing) can range from 0 and 360 degrees. 0 degrees means that you're sailing northwards, 90 degrees means you're sailing eastwards, 180 degrees means you're sailing southwards, and 270 degrees means you're sailing westwards.

Now suppose you have an initial compass bearing of 300 degrees, and then proceed to give your ship a 250 degrees turn. Adding these values together gives a new bearing of 550 degrees. However this value is not on your compass. To find the compass bearing you perform a modulo operation with 360 (because the compass has a range of 360 degrees). So your new bearing is:
$\text{mod}(550,360)=550-\text{floor}(\frac{550}{360})\cdot 360=550-\text{floor}(1.53)\cdot 360)=550-1\cdot 360=190$

8. ## Re: How do I calculate modulo?

Originally Posted by corsica
Maybe it also helps to have a real-world example. Suppose you're navigating a ship with a compass. The compass bearing (the direction in which you're sailing) can range from 0 and 360 degrees. 0 degrees means that you're sailing northwards, 90 degrees means you're sailing eastwards, 180 degrees means you're sailing southwards, and 270 degrees means you're sailing westwards.

Now suppose you have an initial compass bearing of 300 degrees, and then proceed to give your ship a 250 degrees turn. Adding these values together gives a new bearing of 550 degrees. However this value is not on your compass. To find the compass bearing you perform a modulo operation with 360 (because the compass has a range of 360 degrees). So your new bearing is:
$\text{mod}(550,360)=550-\text{floor}(\frac{550}{360})\cdot 360=550-\text{floor}(1.53)\cdot 360)=550-1\cdot 360=190$
Thank you for explaining me this use of mode, which I familiar with...

Before
Sorry... confused!
I wrote something like this
But, what if x=y=1
, but it was a mistake, instead of mod in your post my eyes saw gcd...

So I was confused, but not with your post #3.

Anyway, thanks!