+ 1

A small doubt in Java ❤️ [Solved]

Is "N%2!=0" means odd numbers and "N%2==0" means even numbers? Could you explain this please 🙏

18th Dec 2020, 10:43 AM
Ray
Ray - avatar
4 Réponses
+ 2
It's about what is remaining when divided by 2 So "N"%2!=0 means Whatever number "N" is let's say its 5 if I divide this by 2 im left with remainder 1 which does not equal zero so it has to be an odd number which will return true, it's TRUE that it does not equal 0 Its like having to share 5 coins in real life between 2 people, 2 of those people will have 2 coins and you have the remainder 1
18th Dec 2020, 1:19 PM
D_Stark
D_Stark - avatar
+ 2
Yes. Because odd number is not divisible by 2. And even number is.
18th Dec 2020, 10:53 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
Gl̸̗͓̘̽͂̏̋̽̕ị̶̢̈̔t̴̨̲̫̏̈́̋̈͜ͅc̸̙̬͇̒̋͛h̸̥̯̱̽ thanks bro ❤️, what kind of programmer are you? It seems like you're an ethical hacker....
18th Dec 2020, 2:45 PM
Ray
Ray - avatar
+ 1
Any Numbers which you divided by 2 and get the remainder is not equal to 0 is called odd number.eg : 7/2 then its remainder is 1 . Any Numbers which you divided by 2 and get the remainder is equal to 0 is called even number.eg : 4/2 then its remainder is 0 .
18th Dec 2020, 10:56 AM
Gayathri.M
Gayathri.M - avatar