• BradleyUffner@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 month ago

    My favorite part of this is that they test it up to 99999 and we see that it fails for 99991, so that means somewhere in the test they actually implemented a properly working function.

    • frank@sopuli.xyz
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      No, it’s always guessing false and 99991 is prime so it isn’t right. This isn’t the output of the program but the output of the program compared with a better (but probably not faster) isprime program

      • BradleyUffner@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 month ago

        Yes, that’s what I said. They wrote another test program, with a correct implementation of IsPrime in order to test to make sure the pictured one produced the expected output.

          • AItoothbrush@lemmy.zip
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 month ago

            I mean people underestimate how usefull lookup tables are. A lookup table of primes for example is basically always just better except the one case where you are searching for primes which is more maths than computer programming anyways. The modern way is to abstract and reimplement everything when there are much cheaper and easier ways of doing it.