• Karyoplasma
    cake
    link
    fedilink
    arrow-up
    31
    arrow-down
    2
    ·
    8 months ago
    while (true){
        if (number == 0) return true;
        if (number == 1) return false;
        number -= 2
    }
    
      • Karyoplasma
        cake
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        8 months ago

        You know, shortly after posting this I did think about whether it’s still working if I just pass the underflow that will happen at some point or if I have to fix something in that case (like subtract 1 after the underflow). I deemed it “too complicated” and would just issue a warning that my code is only tested on positive numbers, but I think it will still work.