Languages
[Edit]
EN

Java - check if number is odd or even

7 points
Created by:
isherwood
599

If a number is divisible by two then it is even, otherwise, it is odd.
To find reminder in java we use modulo operator %.

Even numbers always end with a digit of 0, 2, 4, 6 or 8
Odd  numbers always end with a digit of 1, 3, 5, 7 or 9

Examples of even numbers:
2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26

Examples of odd numbers:
1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27

Output:

Reference:

Edit

Wiki - Parity
Modulo in java - syntax, how to use it with examples

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join