Last active
July 15, 2016 08:45
-
-
Save kbiedrzycki/59a926ed1e82273ee7e4c879839530dd to your computer and use it in GitHub Desktop.
Function for checking if number is prime (matching regular expression of unary value)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(value) { | |
const primeVerifyExpression = /^1?$|^(11+?)\1+$/; | |
const unaryValue = '1'.repeat(value); | |
return !primeVerifyExpression.test(unaryValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment