View Single Post
 
Weird prime tests
Reply
Posted 2024-12-24, 07:39 PM
What's your strangest way to check if a number is prime? Here's a Python one using regex:

Code:
import re
def is_prime(n):
    return not re.match(r"^.?$|^(..+?)\1+$","\0"*n)
"Stephen Wolfram is the creator of Mathematica and is widely regarded as the most important innovator in scientific and technical computing today." - Stephen Wolfram
Old
Profile PM WWW Search
Chruser shouldn't have fed itChruser shouldn't have fed itChruser shouldn't have fed itChruser shouldn't have fed itChruser shouldn't have fed it
 
 
Chruser