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

Programmer Humor

25180 readers
1553 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 88 points 1 week ago* (last edited 1 week 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 1 week 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 6 days ago (1 children)

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

[–] Ebber@lemmings.world 5 points 6 days ago

Stack overflow

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