this post was submitted on 15 Jul 2025
279 points (94.3% liked)

Programmer Humor

25448 readers
880 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 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] sus@programming.dev 87 points 2 weeks ago* (last edited 2 weeks ago) (9 children)

After working at blizzard for 51 years, I finally found an elegant solution by using the power of recursion

private bool IsEven(int number){
  if (number > 1) return IsEven(number - 2);
  if (number == 0) return true;
  if (number == 1) return false;
}
[–] Ebber@lemmings.world 13 points 2 weeks ago (4 children)

I removed the tail recursion for you:

private book IsEven(int number) {
    if(number > 1) return IsEven(number - 2) == true;
    if(number == 0) return true; 
    if(number == 2) return false;
}
[–] Ferk@programming.dev 3 points 2 weeks ago (1 children)

What'd be the result for IsEven(1)?

[–] Ebber@lemmings.world 5 points 2 weeks ago

Stack overflow

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