Ad
Mathematics
Algorithms
Logic
Numbers
Code
Diff
  • def prime_checker(n):
        a = 0
        for i in range(2,n):
            if n == 2:
                return True
                break
            elif n%i == 0:
                return False
                a += 1
                break
        if a == 0:
            return True
    • 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:
    • a = 0
    • for i in range(2,n):
    • if n == 2:
    • return True
    • break
    • elif n%i == 0:
    • return False
    • i += 7
    • return True
    • a += 1
    • break
    • if a == 0:
    • return True