this post was submitted on 31 Oct 2024
377 points (98.5% liked)

196

16530 readers
2003 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 22 points 3 weeks ago (2 children)

Ask AI:

public static boolean isEven(int number) {
    // Handle negative numbers
    if (number < 0) {
        number = -number; // Convert to positive
    }
    
    // Subtract 2 until we reach 0 or 1
    while (number > 1) {
        number -= 2;
    }
    
    // If we reach 0, it's even; if we reach 1, it's odd
    return number == 0;
}
[–] [email protected] 29 points 3 weeks ago (1 children)

Anything but using modulo I guess

[–] [email protected] 6 points 2 weeks ago

And bit operations (:

[–] [email protected] 13 points 3 weeks ago (1 children)

This makes me happy that I don’t use genai

[–] [email protected] 6 points 2 weeks ago

I'm not sure how fucked up their prompt is (or how unlucky they were). I just did 3 tries and every time it used modulo.

I'm assuming they asked it specifically to either not use modulo or to do a suboptimal way to make this joke.