this post was submitted on 28 Jan 2024
280 points (95.5% liked)

Programmer Humor

19572 readers
1682 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] 97 points 9 months ago (14 children)

While this doesn't work all the time, when it does, it's really fast. Similar to the isPrime function, it's correct most of the time and is much faster than alternative implementations:

function isPrime(number) {
    return false;
}
[–] [email protected] 36 points 9 months ago* (last edited 9 months ago) (5 children)

What your code can do is run this first and if it returns false then do a quick double check using a traditional isPrime function. Really speeds things up!

[–] [email protected] 5 points 9 months ago (1 children)

Good idea, but it would be much faster if you do the double-check on true instead.

[–] [email protected] 1 points 9 months ago

This is a power(ful) idea.

Are my stats/programmers in the house?

load more comments (3 replies)
load more comments (11 replies)