• BradleyUffner@lemmy.world
    link
    fedilink
    English
    arrow-up
    34
    arrow-down
    2
    ·
    edit-2
    1 day 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
      25
      arrow-down
      4
      ·
      1 day 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
        28
        ·
        1 day 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
            18
            ·
            1 day 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.

            • ozymandias@sh.itjust.works
              link
              fedilink
              arrow-up
              4
              arrow-down
              1
              ·
              24 hours ago

              more maths than computer programming anyways

              Computer programming is a subset of maths and was invented by a mathematition, originally to solve a maths problem…

              • AItoothbrush@lemmy.zip
                link
                fedilink
                English
                arrow-up
                4
                arrow-down
                1
                ·
                23 hours ago

                Yeah but they slowly develop to be their own fields. You wouldnt argue that physics is math either. Or that chemistry could technically be called a very far branch of philosophy. Computer programing, physics, etc are the applied versions of math. You are no longer studying math, you are studying something else with the help of math. Not that it matters much, just makes distinguising between them easier. You can draw the line anywhere but people do generally have a somewhat shared idea of where that lies.

          • draco_aeneus@mander.xyz
            link
            fedilink
            English
            arrow-up
            3
            ·
            24 hours ago

            For prime numbers, since they’re quite difficult to calculate and there’s not that many of them, that’s what’s most common.

    • anton@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      8
      ·
      1 day ago

      That’s a legitimate thing to do if you have a slow implementation that’s easy to verify and a fast implementation that isn’t.