(Sorry in advance if this has been asked before, I searched and couldn't find a similar question)
So I believe modulo (%) gives me the remainder of a long division equation. so 2%4 =0r. So in simple terms a modulo equation that equals zero should be an even number. and a modulo equation that equals 1, should be an odd number? Is that correct?
Here's where I begin to confuse myself.
What about equations that equal an even or odd remainder, would that still output an equal or odd number.
For instance. 5%149 equals 4r.. the remainder is an even number, so is the output all even numbers.. or does the very fact that there is any remainder at all mean that the output will be odd numbers??
TLDR, is modulo as simple as 0r outputs even numbers. And anything with 1 or more remainder outputs odd numbers.
Modulo (or modulus) is used to see the remainder of a division.
You can flip it on it's head and use multiplication to help you out as well if necessary. I've provided some examples.
Try doing something like this:
From the equation you posted in your example:
149 % 5would give you the remainder of 4. Reason for this: The last multiple of 5 you can get before 149 is 145, and your modulus equation is telling you that you have4left over.Now, if you were to do something like 150 % 5, your remainder would be
0because150is a safe multiple of 5.Some documentation should hopefully help you understand this a bit better as well: https://docs.onux.com/en-US/Developers/JavaScript-PP/Language/Reference/Expressions/arithmetic-operators/modulus
Some examples to help you understand the remainder:
10 % 5 = 0Since 5 x 2 = 109 % 3 = 0Since 9 x 3 = 96 % 2 = 0Since 2 x 3 = 67 % 2 = 1Since you can only multiply 2 three times to get 6, you are left with a remainder of 1.