297
Infallible Code (feddit.uk)
submitted 1 week ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 13 points 1 week ago

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;
}
[-] [email protected] 3 points 1 week ago

I didn't get this.

Why return book? Does that have some Blizzard reference?
And why would number == 2return false? This is a function for getting true when the number is even, right?

[-] [email protected] 13 points 1 week ago* (last edited 1 week ago)

Haha, you're right. I've now learned two things:

  1. I should not write code on a mobile
  2. I should not become a proof reader

At the end of the day i just wanted the function to be worse, by causing stack overflows

[-] [email protected] 3 points 1 week ago

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

[-] [email protected] 5 points 1 week ago

Stack overflow

this post was submitted on 15 Jul 2025
297 points (100.0% liked)

Programmer Humor

25246 readers
643 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