Ad
  • Default User Avatar

    n=10000000019

    • this solution: 21.4 ms ± 587 µs
    • faster version: 13.4 ms ± 40.5 µs

    Faster version:

    def prime_checker_6k(n):
        if n < 4:
            return n > 1
        if not (n % 2 and n % 3):
            return False
        for i in range(5, int(n ** 0.5)+1, 6):
            if not ((n % i) and (n % (i + 2))):
                return False
        return True
    
  • Custom User Avatar

    You might wanna try again, It wont work for n <= 1 and n == 4