12 ms·
Is This Prime?
- davjhan 5y agoI love these simple web games! Great idea. One way to improve it is to add some more juice when you answer a question. Right now, the text in the number just swaps to the next question, so any sort of small visual feedback will help first time players get it more. I also like to make these small web mini games on the side. Here's one where you guess the year that famous events happened: https://guess-the-year.davjhan.com/ https://guess-the-year.davjhan.com/
- exo-pla-net 5y agoGood practice for learning divisibility rules https://en.m.wikipedia.org/wiki/Divisibility_rule https://en.m.wikipedia.org/wiki/Divisibility_rule
- Kluny 5y agoI love it, but the game doesn't work for me! No response when I click Yes or No, or using the keyboard y and n. Just the clock ticking down. Chrome Version 91.0.4472.114 (Official Build) (64-bit) on Windows 10 Enterprise.
- gerbler 5y agoI really like it. I wonder if the text could be dropped once it starts. I found myself reading it each time which ended up distracting me a little and sometimes I would rush and tapped the opposite of what I intended.
- whoomp12342 5y agoman, these tech screenings are getting out of control
- optimalsolver 5y agoIs there a reason we're obsessed with primes beyond aesthetics? Why does this set of numbers garner all the headlines as opposed to some other arbitrary integer sequence like the Recamán numbers [0] ? If tomorrow someone discovered a closed-form equation for the nth prime, how would mathematics/the world change? [0] https://en.wikipedia.org/wiki/Recamán%27s_sequence https://en.wikipedia.org/wiki/Recamán%27s_sequence
- Jtsummers 5y agoYour original link 404'd on me (you seem to have replaced it with a different one though). Here's the working Wikipedia link: https://en.wikipedia.org/wiki/Recamán%27s_sequence https://en.wikipedia.org/wiki/Recamán%27s_sequence
- optimalsolver 5y agoThanks. I've edited the link.
- X6S1x6Okd1st 5y agoI'm not sure about a closed-form equation for the nth prime, but if integer factorization can be done in linear time then much of applied cryptography needs to be replaced.
- JJMcJ 5y agoNone is known. Can't be a polynomial.
- johnday 5y agoThe prime numbers are critical in cryptography. Almost all of our current digital security infrastructure is based on the concept of multiplying large numbers together modulo suitably big prime numbers. Any major step towards understanding them (such as a closed-form equation for primes) would have major mathematical knock-on effects which may or may not undermine these methods, or provide us with a basis for even stronger cryptographic mechanisms to make use of in the future.
- whatshisface 5y ago>Almost all of our current digital security infrastructure is based on the concept of multiplying large numbers together modulo suitably big prime numbers. That's not true of elliptic curves.
- 5y ago
- kstrauser 5y ago78. Who did better?
- dhosek 5y agoI was hoping someone would post a score. I got 35, but I kept getting distracted.
- Tempest1981 5y agoWow, you're hired!
- X6S1x6Okd1st 5y agoThey've included 1 as not a prime. That was a fairly recent decision.
- Jtsummers 5y agoIt's not a recent decision. It's a (low grade) debate that's spanned thousands of years now.
- copperx 5y agoWho's they? Is this a mathematical consensus?
- squeaky-clean 5y ago"they" is the game developers of this game.
- drdec 5y agoOne is not a prime number. If you allow one to be a prime number, then you can no longer say that each natural number has a unique prime factorization. This makes the concept of prime numbers much more useful when one is excluded.
- Igelau 5y ago> If you allow one to be a prime number, then you can no longer say that each natural number has a unique prime factorization. I don't dispute that, by definition, 1 is not prime, but I don't see how this statement would follow if we considered it prime. Edit: it seems more like it would be that every factorization would implicitly have 1^n tacked onto it, and while that isn't exactly useful, it doesn't break the game.
- drdec 5y agoThat breaks the uniqueness of the prime factorization. Mathematicians love uniqueness, almost as much as existence.
- sebzim4500 5y agoI'm not sure why but having 'yes' be on the left is really messing me up.
- lalaithion 5y agoThis reminds me of my favorite in-person magic trick to do. First, memorize all the two-digit primes. 25 numbers isn't that hard to memorize. Then, tell someone "Oh, I can instantly tell whether a number is prime or not. Give me a number, I'll tell you whether it's prime." If they tell you a number between 1 and 100, use your memorized list. Otherwise, it's a game of cold reading; if they just generated a random string of many digits, there's a low chance that the number actually is prime. "21923847" is a keysmash, and it's almost certainly not prime, because the frequency of primes goes down as numbers get bigger. And most people will ask you a number, hear "no", and then go check the number's primality. Eventually, they'll look up a number in advance; that number is almost certainly prime.
- float4 5y agoAnd then one day, somebody asks you calmly: "what about 2^31-1"? Better memorise the small Mersenne exponents as well! https://oeis.org/A000043 https://oeis.org/A000043
- the_arun 5y agoAfter 8 attempts, I ran into "Game Over". Was just thinking about the satisfaction for the author of this site. There is just enormous fun in saying - Game Over - to another human :)
- deleted 5y ago[deleted]
- aidenn0 5y agoAlso, most composites are divisible by 2, 3 or 5, all of which are very easy to check (for 3 just sum up the digits and if the result is divisible by 3, the original number is divisible by 3). 49, 77, and 91 are the only composites under 100 that is not divisible by one of those 3 numbers, making memorizing 25 numbers not even necessary. 49 and 77 are obviously composite to me making 91 the only number I bothered memorizing.
- pkulak 5y ago53?
- HeavenFox 5y agoWhen I was a fifth grader in China, we were required to memorize all prime numbers below 100. Curious if that is common in other countries?
- antman 5y agoI don't think so. Remember any other interesting numbers list you needed to memorize?
- tokamak-teapot 5y agoI learned all the integers.
- eCa 5y agoWhat is the highest integer you know?
- agentwiggles 5y agon + 1 ∀ n ∈ N
- asddubs 5y agothat's not an integer, that's a set
- eesmith 5y agoIf I were able to count them out loud, in order? 999 nonillion, 999 octillion, 999 septillion, 999 sextillion, 999 quintillion, 999 quadrillion, 999 trillion, 999 million, 999 thousand, 999. That is (after consulting a table), 1 decillion - 1. I clearly come from from a short scale culture. If I switched to the long scale and Chuquet names I could, of course, go to 999 nonilliard, 999 nonnillion, 999 octilliard, etc.
- tokamak-teapot 5y ago83
- ridiculous_fish 5y agoHere is a "theorem" I learned: every number up to 100 which looks prime, is prime, except 91. Does anyone recall its name?
- jkingsbery 5y agoI think it's called "The Ridiculous Fish Theorem." +1... I lost two games in a row, both times on 91.
- nilstycho 5y agoThis is a great "theorem", thank you! It's easy to determine divisibility by 2, 3, 5, and 11. 7² is also easy because it's a square. 7×13=91 is the only composite number under 100 that isn't caught by these rules.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- bbx 5y agoI agree. And I would add 51 to that.
- jkingsbery 5y agoGreat game! Keyboard short cuts would make it a bit better.
- mcintyre1994 5y agoThe help text says y and n work, I’m on mobile and haven’t tried though.
- hughdbrown 5y agoY and N for yes and no.
- progval 5y agoyou can use left and right arrows
- Igelau 5y agoWhy do I feel like I'm solving someone else's CAPTCHA?
- __michaelg 5y agoFinally a way to sort out candidates that's even cheaper than making them implement B-trees.
- lexlieberman 5y agoI've spent a good week of straight hours on primes by now, the most fun thing I've come up with was this boring sieve. https://github.com/alexlieberman/Prime-Numbers/blob/master/SixSieve.java https://github.com/alexlieberman/Prime-Numbers/blob/master/S...
- Tempest1981 5y agoCoding Ulam's Spiral is also fun: https://en.m.wikipedia.org/wiki/Ulam_spiral https://en.m.wikipedia.org/wiki/Ulam_spiral
- slmjkdbtl 5y agoWould pay to for more chances
- nonfamous 5y agoI’ve always wondered: how feasible is it to implement an “isprime” function, via lookup table? If such methods are used, is cryptography getting weaker and weaker in practice as more large primes are discovered?
- shric 5y agoNo, at the cryptographic scale of prime numbers the lookup table would need to be far too big in terms of both time to generate and storage required. For smaller numbers see various prime sieves (Atkin, Eratosthenes)
- nonfamous 5y agoTime to generate I get, but you could always augment the table over time and fall back to standard methods otherwise (and store the result). Storage I have a harder time wrapping my head around. Aren’t primes quite sparse at cryptographic magnitudes? And are the primes used for (say) 256-bit encryption about the same magnitude, narrowing the dimension of storage required?
- thomasahle 5y agoThe primes are quite dense. There are roughly n/log(n) primes below n. Meaning 1 in 256 numbers with 256 bits are prime. That's 2^(248) primes. For RSA one typically use 2048 or 4096 bit primes.
- not2b 5y agoNatural logarithm (base e, not base 2, so one in 177.4 for 256 bit numbers), but that doesn't change your general point.
- willcipriano 5y agoIf your question is purely "is the value prime" the Fermat primaility test is very fast, probably about as fast as a hash table lookup on a table that large. Running Baillie–PSW to eliminate false positives isn't a huge deal either as it will only need to run if Fermat passes. It's not a horrible idea on its face and may indeed be a little faster, at the cost of lots of memory. I don't know of a use case where it would be worth it.
- koolba 5y agoI was expecting an Amazon product search / review site and was pleasantly surprised that it is in fact a math game.
- Imnimo 5y agoMy prime number skills only go up to 47 because that's how high Number Munchers went.
- Igelau 5y agoI was too busy shooting more meat than I could carry back to the wagon, or fleeing low to escape the osprey.
- andrejewski 5y agoThis is really cool! I made a very similar game a couple years ago: https://jew.ski/prime-time/ https://jew.ski/prime-time/ It's interesting to compare the game play and design. My game is written in Elm and open source if anyone is interested. This website has keyboard inputs (y or n) which is a good idea. My game only does click/touch inputs.
- TheDudeMan 5y agoLove it. But if you are clicking an answer just as time is running out, you won't get to see your score (it starts a new game).
- quercusa 5y agoI've started, if I wake up in the middle of the night, thinking of a 'prime-looking' number, then trying to factor it. Sometimes I discover interesting connections, other times I fall back asleep - either is a win.
- ramshanker 5y agoGame over 1 is non-prime by definition. You correctly sorted 17 numbers.
- crackercrews 5y agoPSA: you can use the arrow keys to answer more quickly.
- deleted 5y ago[deleted]
- ineedasername 5y ago-3
- powerbroker 5y agoI'm using this as a metric to determine if my brain is deteriorating. (my age) + (my best score, without more than a few minutes of 'training') > 80 means I'm still doing OK. Today, at 56 years wise, I scored 34, so 90 > 80. Means I judge myself to be smart enough to put my shoes on the correct feet, still.
- marcodiego 5y agoCool! Now let's try to find a way to make this fit in a fast paced space shooter.
- eesmith 5y agoWhat about a Pac-Man? https://www.youtube.com/watch?v=xKrn5bHn-d8 https://www.youtube.com/watch?v=xKrn5bHn-d8 - Mathman, from the PBS series "Square One Television". A Pac-Man spoof. In this one Mathman must only eat primes.
- tyingq 5y agoIf I click start, then paste some quick and dirty browser automation in the console: function c(){is_prime(document.getElementById('n').textContent)==="prime"?yes.click():no.click();window.setTimeout(c,1)};c() My old laptop can guess right 16k times and get up to 4172973243025599, but then the http post to do the stats (record.php) bombs with a MySql error "Out of range value for column 'end' at row 1" :)
- standyro 5y agoI guess it wouldn’t be HN if your side project’s database didn’t crash because you didn’t choose the right data type, haha. Looks like it gracefully failed though, could be worse. I’m afraid that the stats page is too easy to DDOS though.
- dexterhaslem 5y agolook at the entries lol, looks like it had an injection heyday back when first released
- lifthrasiir 5y agoThat made me wonder how the game determines if the number is a prime or not. Turns out it's the Miller-Rabin test with a deterministic variant used for the range (up to 2^53) the game supports. I don't know why the game internally uses a bigint implementation while only supporting numbers up to 2^53 though...
- perryizgr8 5y ago> 1 is non-prime by definition. This made me sad :(
- eesmith 5y agoIn practice, it turns out to be more convenient if the definition excludes 1, rather than put a qualifier in every place which uses the term "prime". For example, it's more convenient to write "every integer greater than 1 is a unique product of prime numbers" than to say "every integer greater than 1 is a unique product of {prime numbers excluding 1}" (That's the fundamental theorem of arithmetic https://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic https://en.wikipedia.org/wiki/Fundamental_theorem_of_arithme... .)
- josephcsible 5y agoAfter lots of 2-digit numbers ending in 5 came up, my brain went on autopilot thinking "any number that ends in 5 is not a prime". I lost when 5 came up.
- spoonjim 5y agoI think this question is framed the wrong way for me. I think if the question was "Is this composite?" I would get much better scores. The way I think is "Does it have a factor?" and inverting that Boolean trips me up.
- W0lf 5y agoI am not doing _that_ type of number crunching in my daily work, so the following check (in Python) has probably lots of potential for improvement: def is_prime(n): return not True in [n%x == 0 for x in range(2, n/2)]
- PirateAvogadro 5y agoYou don't need to test up to n/2, just floor(sqrt(n)) will do even better you only need to test the primes <= floor(sqrt(n))