Check the number even or odd without using division or modules | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Check the number even or odd without using division or modules

tell someone plz

9th Sep 2018, 1:19 PM
M.Santhosh Kumar
4 Answers
+ 4
% is a division operation. a & 1 == 0 in case if a is odd.
9th Sep 2018, 1:54 PM
Sergey Ushakov
Sergey Ushakov - avatar
+ 3
(n>>1)<<1==n is true if n is even
9th Sep 2018, 2:36 PM
Anna
Anna - avatar
+ 1
n % 2 == 0 returns true if n is even
9th Sep 2018, 1:51 PM
ReimarPB
ReimarPB - avatar
+ 1
Check if last digit is in [0, 2, 4, 6, 8] or in [1, 3, 5, 7, 9]
9th Sep 2018, 2:04 PM
Emerson Prado
Emerson Prado - avatar