Modulo problem 9 is broke again


#1

~~~
public class Modulo {
public static void main(String[] args) {

	int myRemainder = 11 % 2
  
 		System.out.println(myRemainder);

}

}
~~~

This isn't working. I looked at another thread that said it was fixed but I have tried 7 or 8 different problems only to have it come back with errors. and I cant skip the problem. Please fix this again.


#2

What remainder is the exercise asking for?


#3

They're asking for remainder 2


#4

In that case, you must create your equation so that the remainder is 2.

That equation would have remainder 1.


#6

Your goal is to create an equation using % that results in 2.

That means a division question where the remainder is 2.

Is that clear now?


#7

why won't 10 % 5 work? 10/5=2 yes?


#8

% is not the same as /

10 / 5 = 2 remainder 0
10 % 5 = 0


#9

why 4 % 2 is not working


#11

as albionsrefuge said, % is not the same as /

you want an equation with a remainder of 2

4/2 = 2 but the remainder is 0


#12

use a basic algebra formula to figure out what numbers you need, easiest way to do this is start out with a number that already has a remainder of 2 and multiplying it by a whole number. this works because a/b=c is the same as a=b*c so if you have a/3=4.2 it is the same as a=3*4.2 or a= 12.6 so if you put into the code 26.6%3 the return will be the remainder, which is 2.


#13

Hi p_web !

It seems as though many people following your post do not know what division is ( no offense.. ).

To help all of you:

10/5 = 2. 10 is the dividend, 5 is the divisor and the 2 is the quotient.
10%5 = 0. Modulo gives us the remainder- in this case 0

QUOTIENT AND REMAINDER ARE NOT THE SAME TERMS !!

here is an example of a remainder type- 3%2 = 1

Why? here is the math!! 2 times 1 is 2, and 3-2=1 !! So the remainder is one!! ( Khan Academy can teach you elementary school division if you need help.. )

-PythonMaster


#14

pythonmaster333

someone had to say it...

The problem works. Some of you need to slow down a little and understand the math term modulo. Every example I saw from someone saying it doesn't work had numbers that did not have a remainder of 2 ( as per the requirement ).


#15

why wouldn't 22 % 10 work? I did this in the exercise and did not give me my remainder as expected. I ended up with 7 % 5 which did work.


#16

Thank You!! I appreciate that you see how it works :slight_smile:


#17

If you need a remainder of two, simply do n % n - 2. Will always be 2 as long as n is above 4.
Edit: see for yourself

Function< Integer, Boolean> isRemainderTwo = (num) -> (num > 2) && (num % (num - 2)) == 2;
IntStream.range(0, 100000).forEach(i -> System.out.println(i + ": " + isRemainderTwo.apply(i)));

Edit 2: this goes for pretty much any number I believe


#18

Guys are there any good books on Modulo! I want to brush away my cobwebs on maths.


#19

This is simple.

7%5=2
If 7/5=1.4
Then 5*1=5
Then 7-5=2

or,

26%3=2
If 26/3=8.666......
Then 3*8=24
Then 26-24=2

Simple right?


#20

ok: nothing about maths... It is a rule. The remainder result from multiplying the result of the division without any importance of decimals...


#21

I was using that as an example. Showing how the math would work. Am I wrong?

I have found concepts to be more understandable with practical application.


#22

25% de 2 :grinning: y eso no màs pude hoy pero hay màs formas