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.
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.