Geeze guys. All the guy does is try to have some good programming fun and you get all in a fit.
Absurdly foolish method of checking for primality using the absurdly foolish technology known as the "regular expression."
This might as well be a duplicate. There's no meaningful content that isn't already on the original page.
From the page: "A regular expression to check for prime numbers"
This seems really handy. Only thing is i really need to look into why this stuff works :)
From the page: "A PHP Version:
!preg_match(窶/^1?$|^(11+?)1+$/x窶, str_repeat(窶1窶ｲ, $n))
There is beauty in the infinite set of primes. . .
Clever, but useless. If it could check a decimal representation that would be fantastic, but converting it into a string of ones first means that there are always much more efficient ways to check primality.
check prime numbers in ruby using regular expressions
that is spooky cool...
Enter any 11 digit prime number to continue....
A thingie that checks if a number is "prime" that looks too simple, too impossible but is understandable due to the point-by-point explanation. Up til now we've been discovering reality but I think Programmers are beginning to create reality.
Wow, and I thought I wrote esoteric code ^_^
1 line (regex) primality test...i wanna prove this...too bad i suck at regex (edit: its "proven" i guess...kinda stupid, but nice to get it in one line..didn't know regex could do that...)