Re:A regular expression to check for prime numbers
by johnfn on Wednesday June 21, 2023 @02:23AM
(#36415072)
Come now, every time a colleague says they parsed a file with a regex in javascript, do you turn to them and tell them "well, you didn't actually use a _regular_ expression..."
[ Parent
| on HN ]
Re:A regular expression to check for prime numbers
by unhammer on Wednesday June 21, 2023 @02:48AM
(#36415218)
Only every time they claim a major mathematical breakthrough using regular expressions.
Re:A regular expression to check for prime numbers
by underdeserver on Wednesday June 21, 2023 @04:21AM
(#36415856)
Nobody claimed that.
Re:A regular expression to check for prime numbers
by SerpentJoe on Wednesday June 21, 2023 @11:27AM
(#36419781)
It's true, the article doesn't make that claim. We think of primes as being mysterious and out of reach, and we're conditioned to think "mathematical / computational breakthrough" when we read the words "prime number" in a headline, but this is only because we've found all of them that aren't huge enough to be mysterious. Computing prime numbers is trivial as long as you don't mind them being the same ones everybody else already found.
Re:A regular expression to check for prime numbers
by Tainnor on Wednesday June 21, 2023 @03:34PM
(#36423239)
Not sure what you mean by "trivial", I mean a simple prime finding algorithm is easy to write down, but it will be very inefficient, especially for large primes (the very ones you use in cryptography).
Coming up with an efficient prime-finding algorithm like Miller-Rabin* is far from trivial.
* Technically it's just a prime-checking algorithm, but you can just generate random numbers until you've verified one of them is prime.
Re:A regular expression to check for prime numbers
by Tade0 on Wednesday June 21, 2023 @06:16AM
(#36416670)
I do find it useful to know that regular expressions in JS(and many other languages really) are not actually regular and why - allows one to decide if a given problem can be solved at all using them.