this post was submitted on 28 Dec 2023
4 points (100.0% liked)

Programmer Humor

19570 readers
1649 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 0 points 10 months ago (2 children)

Could be easily made 50% space saving by only iffin all odds and return even on else. Maybe one if before to handle overflow to avoid wrong even if over the last if.

[–] [email protected] 0 points 10 months ago* (last edited 10 months ago)

Yeah but then ALL even numbers would be slow to compute because you would have to chain through every odd before you know that 2 is even.

Depends on the expected distribution of input values

[–] [email protected] 0 points 10 months ago

Well yeah, if you allow cheating!