Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
Regular Expression That Checks If a Number Is Prime (2016)
(opens in new tab)
(iluxonchik.github.io)
4 points
jagtodeath
6y ago
1 comments
Save
Share
1 comments
1 comments · 1 top-level
top
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