regex
Regex prime checker
This Java snippet uses a regular expression for something way different than they were designed for: a primality check.
public static boolean prime(int n) {
return !new String(new char[n]).matches(".?|(..+?)\\1+");
}…