394
Rule (lemmy.blahaj.zone)
submitted 1 month ago by Persona3Reload to c/196
you are viewing a single comment's thread
view the rest of the comments
[-] lnxtx@feddit.nl 23 points 1 month ago

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;
}
[-] Sanctus@lemmy.world 29 points 1 month ago

Anything but using modulo I guess

[-] lnxtx@feddit.nl 6 points 1 month ago

And bit operations (:

[-] YtA4QCam2A9j7EfTgHrH@infosec.pub 16 points 1 month ago

This makes me happy that I don’t use genai

[-] Mirodir@discuss.tchncs.de 7 points 1 month 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.

this post was submitted on 31 Oct 2024
394 points (100.0% liked)

196

16724 readers
2182 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 2 years ago
MODERATORS