• quickpen@sh.itjust.works
    link
    fedilink
    arrow-up
    10
    ·
    1 year ago

    I don’t get it. Can someone Explain Like I’m 5?

    There is a function that always returns false, and then a bunch of random output, and one failed?

    Is this like another weird quirk in the JavaScript VM or something? Lol?

    • kman@lemm.ee
      link
      fedilink
      arrow-up
      23
      ·
      edit-2
      1 year ago

      Prime numbers become less frequent as the numbers get larger, so if you want to implement a function that tests whether a number is prime, just always returning false will get more and more accurate as you count up. The console output is just saying whether it was correct to say the number isn’t prime, and the percent is the accuracy over the previous numbers

      • quickpen@sh.itjust.works
        link
        fedilink
        arrow-up
        14
        ·
        1 year ago

        Ohhhh, so there isn’t anything crazy going on here.

        It’s just literally running that function and tallying up how accurate it is as a prime number checker.

        …and it gets more accurate the longer it runs. Okay, I see now. Thanks, lol.