Jul
16th
Thu
16th
Regex to determine prime numbers
Convert the number to a series of 1s - so 4 becomes 1111 - and use this regex to check if it’s prime.
/^1?$|^(11+?)\1+$/
Very clever. Read this for an explanation.