Search Results

Search found 1 results on 1 pages for 'kitlite'.

Page 1/1 | 1 

  • Determine if a number is a prime with regex?

    - by kitlite
    I found the following code example for Java on RosettaCode: public static boolean prime(int n) { return !new String(new char[n]).matches(".?|(..+?)\\1+"); } I don't know Java in particular but understand all aspects of this snippet except for the regex itself I have basic to basic-advanced knowledge of Regex as you find it in the built-in PHP functions How does .?|(..+?)\\1+ match prime numbers?

    Read the article

1