# FAQ: Introduction to Java - Math: %

#1

This community-built FAQ covers the “Math: %” exercise from the lesson “Introduction to Java”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise Math: %

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

#2

#3

Starting with Java, rather than JavaScript is a bit like jumping into the deep end before learning to tread water. You will find the JavaScript course a little easier going and will give you an opportunity to work in a little more forgiving environment.

What level of maths have you reached? Do you understand long division?

#4

What am I missing here? The explanation says for us to use % and not /, but when I try with %, I get it wrong and when I try with a /, I get it right.

1. 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.

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` .

Correct ( int myRemainder = 4 / 2;)
Wrong ( int myRemainder = 4 % 2;)

What am I missing?

Thanks!

#5

What will be the remainder of 4 divided by 2?

Think in algebraic terms…

``````x % a = 2
``````

Let’s throw something into the mix, the quotient…

``````x - q * a = R
``````

In any division, `a > R`, and if we let `q = 1` we have,

``````x - a = 2
``````

which means we can substitute any number for `a` so long as it is greater than 2.

``````x = 2 + 3

5 % 3 = 2
``````

which in program terms, means,

``5 % 3 == 2    // true``

#6

Can you not use any number with a remainder of 2 such as 10 % 4 or 68 % 33? These have an answer of 2 r 2, or is it only supposed to be 1 r 2. Both above examples threw an error in the code.

#7

The lesson instruction says we can use any two numbers, so I’m not sure what the issue might be. Did you try,

``````5 % 3
``````

?