this post was submitted on 15 Jul 2025
462 points (94.8% liked)

Programmer Humor

37322 readers
228 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] thann@lemmy.dbzer0.com 9 points 1 week ago (8 children)

You could use a loop to subtract 2 from the number until it equals one or zero

[–] TimeSquirrel@kbin.melroy.org 8 points 1 week ago (7 children)

Or literally just look at its binary representation. If the least significant digit is a "1", it's odd, if "0", it's even. Or you can divide by 2 and check for a remainder.

Your method is just spending time grinding away CPU cycles for no reason.

[–] theherk@lemmy.world 4 points 1 week ago

Wasn’t the fun the CPU cycles we wasted along the way?

load more comments (6 replies)
load more comments (6 replies)