Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
Regular Expression That Checks If a Number Is Prime (2016) | Better HN
Regular Expression That Checks If a Number Is Prime (2016)
(opens in new tab)
(iluxonchik.github.io)
4 points
jagtodeath
6y ago
1 comments
Share
1 comments
default
newest
oldest
jagtodeath
OP
6y ago
A python implementation of is_prime(n):
return re.compile(r'^1?$|^(11+)\1+$').match('1' * n) is None
j
/
k
navigate · click thread line to collapse