this post was submitted on 15 Jul 2025
432 points (94.6% liked)

Programmer Humor

37233 readers
25 users here now

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

Rules:

founded 5 years ago
MODERATORS
(page 3) 43 comments
sorted by: hot top controversial new old
[–] Midnitte@beehaw.org 5 points 2 days ago

When did Thor become the dev for Yandere Simulator?

[–] Valmond@lemmy.world 1 points 1 day ago
[–] dsilverz@calckey.world 2 points 2 days ago (1 children)

@sirico@feddit.uk

private bool isEven(int number){
    	bool result = true;
    	while (number > 0){
    		number = number - 1;
    		if (result == true)
    			result = false;
    		else
    			result = true;
    	}
    	return result;
    }

(P.S.: Only works for positive numbers)

[–] jaupsinluggies@feddit.uk 3 points 2 days ago

This works for both positive and negative numbers:

private static bool isEven(int number)
{
	bool result = true;

	while (number < 0)
	{
		number = number - 1;
		if (result == true)
			result = false;
		else
			result = true;
	}
	while (number > 0)
	{
		number = number - 1;
		if (result == true)
			result = false;
		else
			result = true;
	}
	return result;
}

Output:

isEven(4) = True
isEven(5) = False
isEven(-4) = True
isEven(-5) = False
[–] jerkface@lemmy.ca 2 points 2 days ago (1 children)

what's the humour supposed to be

[–] dwindling7373@feddit.it -1 points 2 days ago* (last edited 2 days ago) (1 children)

It's a common challenge, such as in interviews, to write code that can return if a number is even or odd.

[–] jerkface@lemmy.ca 2 points 2 days ago (4 children)
[–] dwindling7373@feddit.it 1 points 2 days ago

Yes because that's the dumbest smartest way to do it?

It's an old joke though, I'll give you that.

load more comments (3 replies)
[–] tulliandar@lemmy.world 2 points 2 days ago (1 children)

Why is it all in italics?! I’d reject the PR just for that. Otherwise LGTM

[–] CanadaPlus@lemmy.sdf.org 1 points 2 days ago* (last edited 2 days ago)

deleted by creator

load more comments
view more: ‹ prev next ›