2012/11/21

BDSM reminder

-Werror -Wall -Wextra -Wbad-function-cast -Wcast-align -Wcast-qual -Wconversion 
-Wfloat-equal -Wformat=2 -Wlogical-op -Wnested-externs -Wno-missing-braces 
-Wno-missing-field-initializers -Wold-style-definition -Wpointer-arith 
-Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-overflow=5 
-Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wunreachable-code -Wwrite-strings

(c) _winnie

2012/11/03

How to determine if a number is a prime with regex?

public static boolean prime(int n) {
  return !new String(new char[n]).matches(".?|(..+?)\\1+");
}
The explanation is on the StackOverflow.