Created
June 20, 2018 12:07
-
-
Save e-mihaylin/cb7f99d084c06afccd588481e2b1d80f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const regexDivisibleBy = n => { | |
if (n == 1) return '^(0|1)+$'; | |
if (n == 2) return '^(0|1)+0$'; | |
if (n == 3) return '^(0*(1(01*0)*1)*)*$'; | |
if (n == 4) return '^(0|1)+00$'; | |
if (n == 5) return '^(0|1(10)*(0|11)(01*01|01*00(10)*(0|11))*1)+$'; | |
if (n == 6) return '^(0|(11|1(00|011*0)(00|011*0)*1)(11|1(00|011*0)(00|011*0)*1)*0)+$'; | |
if (n == 7) return '^(0|(10((0|11)(1|00))*(10|(0|11)01)|11)(01*0(0|101|1(1|00)((0|11)(1|00))*(10|(0|11)01)))*1)+$'; | |
if (n == 8) return '^(0|1)+000$'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment