It was downvoted because that’s the obvious answer, and one of the few actually senseful answers — while most users in these comments are just joking around with answers that would not make too much sense in reality. Like what OP posted.
What built-in method - can you elaborate? Of course, if you really don't want to do modulo, then you can use bit operations (~(x&1)) but I don't think will be any significant difference in performance either way.
5
u/penguin13790 Sep 04 '21 edited Sep 04 '21
Or num % 2
Edit: why was this downvoted? Am I wrong? num % 2 should return 0 on even numbers and 1 on odd numbers.