Ad
Code
Diff
  • def is_prime(n):
        return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
    • from math import sqrt
    • def is_prime(n):
    • return n > 1 and all(n % i for i in range(2, int(sqrt(n))+1))
    • return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))
Code
Diff
  • from math import sqrt
    def is_prime(n):
        return n > 1 and all(n % i for i in range(2, int(sqrt(n))+1))
    • import math
    • from math import sqrt
    • def is_prime(n):
    • if n % 2 == 0 and n > 2:
    • return False
    • for i in range(3, int(math.sqrt(n)) + 1, 2):
    • if n % i == 0:
    • return False
    • return True
    • return n > 1 and all(n % i for i in range(2, int(sqrt(n))+1))