all 51 comments

sorted by: hot top controversial new old
[–] 74 points 8 months ago

The error is ~1/log(x), for anyone interested.

  • source
  • [–] 62 points 8 months ago (4 children)
  • [–] 24 points 8 months ago

    you can increase its accuracy by changing the parameter type to long

  • source
  • [–] 38 points 8 months ago* (1 child)

    LLMs belong to the same category. Seemingly right, but not really right.

  • source
  • hideshow 1 child comment
  • [–] 15 points 8 months ago

    I have seen that algorithm before. It's also the implementation of an is_gay(Image i) algorithm with around 90% accuracy.

  • source
  • [–] 32 points 8 months ago* (14 children)

    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.

  • source
  • hideshow 14 child comments
  • [–] 25 points 8 months ago (12 children)

    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

  • source
  • parent
  • hideshow 12 child comments
  • [–] 35 points 8 months ago (11 children)

    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.

  • source
  • parent
  • hideshow 11 child comments
  • [–] 40 points 8 months ago (8 children)

    Plot twist: the test just checks to see if the input exists in a hardcoded list of all prime numbers under 100000.

  • source
  • parent
  • hideshow 8 child comments
  • [–] 20 points 8 months ago (6 children)

    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.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 4 points 8 months ago (5 children)

    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...

  • source
  • parent
  • hideshow 5 child comments
  • [–] 3 points 8 months ago (4 children)

    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.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 10 points 8 months ago (2 children)

    It has actually 100% accuracy

  • source
  • hideshow 2 child comments
  • [–] 7 points 8 months ago

    100% of the time, baby =)

  • source
  • [–] 6 points 8 months ago

    Pssh, mine uses a random number generator for odd numbers to return true 4% of the time to achieve higher accuracy and a bettor LLM metaphor

  • source
  • [–] 13 points 8 months ago (7 children)

    If you scaled it based on the size of the integer you could get that up to 99.9% test accuracy. Like if it's less than 10 give it 50% odds of returning false, if it's under 50 give it 10% odds, otherwise return false.

  • source
  • hideshow 7 child comments
  • [–] 4 points 8 months ago (4 children)

    That would make it less accurate. It's much more likely to return true on not a prime than a prime

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 8 months ago (2 children)

    Correct. Not are why people are upvoting. If 10% of numbers are prime in a range, and you always guess false, you get 90% right. If you randomly guess true 10% of the time, you get ~80% right.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 15 points 8 months ago (5 children)

    I'm struggling to follow the code here. I'm guessing it's C++ (which I'm very unfamiliar with)

    bool is_prime(int x) {
        return false;
    }
    

    Wouldn't this just always return false regardless of x (which I presume is half the joke)? Why is it that when it's tested up to 99999, it has a roughly 95% success rate then?

  • source
  • hideshow 5 child comments
  • [–] 32 points 8 months ago (2 children)

    I suppose because about 5% of numbers are actually prime numbers, so false is not the output an algorithm checking for prime numbers should return

  • source
  • parent
  • hideshow 2 child comments
  • [–] 11 points 8 months ago (1 child)

    Oh I'm with you, the tests are precalculated and expect a true to return on something like 99991, this function as expected returns false, which throws the test into a fail.

    Thank you for that explanation

  • source
  • parent
  • hideshow 1 child comment
  • [–] -5 points 8 months ago* (last edited 8 months ago) (6 children)

    I mean, an application could exist where this isn't even wrong. Maybe as a "subroutine" of another algorithm that only needs a truly composite number most of the time to work.

    That this reads as a joke says a lot about what application we're intuitively expecting.

    Edit: Not sure why this is being downvoted.

  • source
  • hideshow 6 child comments
  • [–] 1 point 8 months ago* (5 children)

    Edit: Not sure why this is being downvoted.

    Perhaps because it would do better, being replaced with noop.

    A link time optimiser might actually do so.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 1 point 8 months ago* (4 children)

    That's kind of what I meant by putting "subroutine" in quotes. You obviously wouldn't write it like this, you'd just use a random large number with a bit of explanation.

    Oh well, live and learn. I'll try to be clearer next time.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 0 points 8 months ago* (3 children)

    I just took the above comment as continuing the joke, but this explanation actually confuses me more.
    Well, I don't really think you need to be very clear in this case. Jokes are more fun when you "get" them rather than have them explained.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 2 points 8 months ago* (last edited 8 months ago) (2 children)

    I get OP was a joke, but I was trying to make a serious observation.

    Say you have some kind of stochastic algorithm that works on the assumption it's fed a composite number most of the time. Maybe something like Pollard's Rho algorithm, where whatever number theoretic structure you need accumulates slowly over time as a result. You decide to just pick a large number at random for each iteration.

    Implicitly, you've solved the problem of finding a composite number by assuming all (large) numbers are composite, like in this post. It is pretty close, like also mentioned in this post. If that's not good enough, you could also use a primality test that fails some small portion of the time, which do exist, and use less power than guaranteed tests.

  • source
  • parent
  • hideshow 2 child comments