• lnxtx (xe/xem/xyr)
    link
    fedilink
    English
    212 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;
    }
    
    • @Sanctus
      link
      English
      292 months ago

      Anything but using modulo I guess

      • @[email protected]
        link
        fedilink
        62 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.