Ad
Mathematics
Algorithms
Logic
Numbers
Code
Diff
  • def prime_checker(n):
        if n < 4 or n==5:
            return n > 1
        if n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
            return False
        i = 7
        sqrt_n = int(n ** 0.5)
        while i <= sqrt_n:
            if n % i == 0 or n % (i + 2) == 0:
                return False
            i += 7
        return True
    • def prime_checker(n):
    • if n < 4:
    • if n < 4 or n==5:
    • return n > 1
    • if n % 2 == 0 or n % 3 == 0:
    • if n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
    • return False
    • i = 5
    • i = 7
    • sqrt_n = int(n ** 0.5)
    • while i <= sqrt_n:
    • if n % i == 0 or n % (i + 2) == 0:
    • return False
    • i += 6
    • i += 7
    • return True