Live data from Hacker News

Primel – guess a 5 digit prime number – each guess must be a prime

converged.yt

31–40 of 139 posts

Re: Primel – guess a 5 digit prime number – each guess must be a prime

#31
post #18

12347 - 65393 ++-- [solution next - omitted for spoiler reasons] I was more surprised about how little trial and error I needed to find primes than about how few guesses it actually took...

Same, I was so surprised to get it solved at the second row, after ~8 attempts to find a prime without the numbers that had not matched. 12347 - [solved]

It seems a lot of us came up with 12347 for the first line.

Re: Primel – guess a 5 digit prime number – each guess must be a prime

#32
post #20

So are people just really good with numbers? I don't know any 5 digit primes nor do I know a way to calculate them on the fly.

apparently 9.3% of all '5 digit' numbers are prime, so random guessing isn't a bad strategy - you'll find one in 10.75 totally randomly chosen numbers to be prime. Being a little smarter, prime number can only end in a 1, 3, 7 or 9 - (ending in 0, 2, 4, 6, 8 would be even, ending in 5 would be odd), so in fact it's more like 25% of 'likely' guesses.

IIRC, randomly guessing is _always_ a good strategy for "give me a prime in the range [a, b]" , in other words that's what's used for algorithms that need primes anyway. Either guess and check or guess and increase-by-2-until-prime.

Does work _much_ better in this range than at crypto sizes though.

Re: Primel – guess a 5 digit prime number – each guess must be a prime

#34
post #31
post #18

Earlier quoted context omitted.

Same, I was so surprised to get it solved at the second row, after ~8 attempts to find a prime without the numbers that had not matched. 12347 - [solved]

It seems a lot of us came up with 12347 for the first line.

While natural in terms of just inputting numbers, it's also not bad to use as first guess because primes are denser (in an "average absolute distance" sense) the lower the magnitude you're around. Without having checked, I would expect there to be more primes of the form 123** than 987**, so you're more likely to gain correct digits with this guess.

Edit: I checked, it's 9 vs 8 primes. But nearby prefixes also have more and there's a lot of variance. Still, there are overall more primes among the same range of smaller numbers (1000-5499 has ~4400 primes, 5500-99999 has ~4000).

Note that, despite this, you probably shouldn't include 0 in the starting guess (e.g. 10247) because 0 will be in the solution less frequently (can't be the leading digit), meaning you gain less info on average.

Re: Primel – guess a 5 digit prime number – each guess must be a prime

#36
Looks very nice. However it took me a while to figure out why I kept getting error. It wasn't obvious to me that you are required to enter prime numbers only. Maybe consider dropping this constraint?

Also, might want to disable text selection via css because I kept selecting the numbers on the button on my phone.

Re: Primel – guess a 5 digit prime number – each guess must be a prime

#37

So are people just really good with numbers? I don't know any 5 digit primes nor do I know a way to calculate them on the fly.

Its a weird thing where in smaller scales, primes numbers that LOOK prime are decent candidates of actually being prime.
Post reply on HN