Mathematics

Algorithms

Logic

Numbers

Mathematics

Algorithms

Logic

Numbers

Fun with regexp

`import re def prime_checker(n): return re.match(r'^1?$|^(11+?)\1+$', '1' * n) == None`

**from math**import**sqrt****primes = [2]**- import
**re** - def prime_checker(n):
**global primes****for p in primes:****if n == p:****True****if n % p == 0:****return False****for c in range((l := primes[-1]) + l % 2 + 1, int(sqrt(n)), 2):****if prime_checker(c):****primes.append(c)****if n % c**==**0:****return False****return Tru**e- return
**re.match(r'^1?$|^(11+?)\1+$', '1' * n)**==**Non**e