this post was submitted on 31 Oct 2024
383 points (99.0% liked)
196
16490 readers
2452 users here now
Be sure to follow the rule before you head out.
Rule: You must post before you leave.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Just divide the number into its prime factors and then check if one of them is 2.
I remember coding actionscript in Flash and using modulo (%) to determine if a number was even or odd. It returns the remainder of the number divided by 2 and if it equals anything other than 0 then the number is odd.
Yeah. The joke is that this is the obvious solution always used in practise, but the programmer is that bad that they don't know it and use some ridiculous alternative solutions instead.
I believe that's the proper way to do it.