|laziness, impatience, and hubris|
Re^4: Prime Number Finderby tall_man (Parson)
|on Mar 08, 2005 at 00:04 UTC||Need Help??|
The regular expression match tries to break the string "111.." (a string of 1's as long as your input number) into some number of equal-length pieces of length two or more. It uses non-greedy matching, so it starts with the smallest possible and works up.. "11","111","1111" and so on. This is the same order of efficiency as the OP's prime test loop (one at a time), but it uses the regular expression engine.