Ad
Code
Diff
  • from math import sqrt
    
    def prime(x):
        return sum([1 if x % i == 0 else 0 for i in range(2, min(int(sqrt(x) + 1), x))]) == 0
    • from math import sqrt
    • def prime(x):
    • end = min(int(sqrt(x) + 1), x)
    • return all(x % i != 0 for i in range(2, end))
    • return sum([1 if x % i == 0 else 0 for i in range(2, min(int(sqrt(x) + 1), x))]) == 0
Code
Diff
  • def prime(x):
        counter = 0
        for i in range(2, x):
            if x % i is 0:
                return False
        return True
    • def prime(x):
    • counter = 0
    • for i in range(1,x):
    • for i in range(2, x):
    • if x % i is 0:
    • counter += 1
    • if counter is 0:
    • return True
    • else:
    • return False
    • return False
    • return True