387
Rule (lemmy.blahaj.zone)
submitted 7 months ago by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 22 points 7 months 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;
}
[-] [email protected] 29 points 7 months ago

Anything but using modulo I guess

[-] [email protected] 6 points 7 months ago

And bit operations (:

[-] [email protected] 14 points 7 months ago

This makes me happy that I don’t use genai

[-] [email protected] 7 points 7 months 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
387 points (98.3% liked)

196

17913 readers
416 users here now

Be sure to follow the rule before you head out.


Rule: You must post before you leave.



Other rules

Behavior rules:

Posting rules:

NSFW: NSFW content is permitted but it must be tagged and have content warnings. Anything that doesn't adhere to this will be removed. Content warnings should be added like: [penis], [explicit description of sex]. Non-sexualized breasts of any gender are not considered inappropriate and therefore do not need to be blurred/tagged.

If you have any questions, feel free to contact us on our matrix channel or email.

Other 196's:

founded 2 years ago
MODERATORS