# Modulo

Instructions state that using the % sign with two numbers will give you what is left over but then said the 7 % 5 = 2 wtf
That does not go with the rules stated below verbatim:

The modulo operator - represented in Java by the % symbol - returns the remainder of dividing two numbers.
For example, 15 % 6 will return the value of 3, because that is the remainder left over after dividing 15 by 6.

My instructions:
1.
Use the modulo operator to set the variable myRemainder equal to 2. You can use any two numbers that return a remainder value of 2.

I did this with initially 19%8 but no that wasn’t correct…where is my disconnect where 7%5 equals 2

This is correct.

7 / 5 gives us 1 with remainder 2

With the example give 15%6 equals 3…i saw 6 going into 15 twice and remaining amount being 3…i did not however view this as what is left after the decimal point…I am not comprehending…is there any way to break it down further because what do you mean there is two left over? With a calculator 7/5 equals 1.4 not 1.2

I would stop thinking about those decimal values and just think about whole numbers.

5 goes into 7 once, and then there is 2 left over.
That 2 is what you get when you do a modulo operation.

15%6
6 goes into 15 twice (12), after that there is 3 left over.

Here is 7 / 2 giving 3 with a remainder of 1
OR: 7 % 2 = 1

3 Likes

I had the same issue and just realised I was missing the semicolon “;” at the end of the line… ;

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.