By mWo12
via noulakaz.net
Published: Jul 22 2010 / 08:02
| Core Spring Data | |
| Written by: Oliver Gierke | |
| Featured Refcardz: Top Refcardz: | |
| 150+ Refcardz Available · Get them all | |
By mWo12
via noulakaz.net
Published: Jul 22 2010 / 08:02
Comments
mpo replied ago:
Uh, ok. Took some time to understand you first have to transform your number into a sequence of ones.
1 > 1 > match (no prime)
2 > 11 > no match (prime)
3 > 111 > no match (prime)
4 > 1111 > match (no prime)
etc etc
Allow me to question this technique as being practical for checking if let's say 25209506681 is a prime or not.
Scoundrel replied ago:
This isn't a regular expression, really. The \1 refers to the last match, and that requires remembering your matches -- and that's not strictly a regular expression... you need more than a Finite State Machine and it takes more than linear time to evaluate. (see Patterns for non-regular languages in http://en.wikipedia.org/wiki/Regular_expression).
For description of how this works, see http://montreal.pm.org/tech/neil_kandalgaonkar.shtml,
Voters For This Link (28)
Voters Against This Link (1)