def prime(x): if x <= 1: return False for i in range(2,int(x/2)): if x % i is 0: return False return True
- def prime(x):
counter = 0for i in range(1,x):- if x <= 1:
- return False
- for i in range(2,int(x/2)):
- if x % i is 0:
counter += 1if counter is 0:return Trueelse:return False- return False
- return True
test.assert_equals(prime(12345),False) test.assert_equals(prime(36),False) test.assert_equals(prime(36),False) test.assert_equals(prime(0), False) test.assert_equals(prime(1), False) test.assert_equals(prime(2), True) test.assert_equals(prime(7), True) test.assert_equals(prime(13), True) test.assert_equals(prime(97), True) test.assert_equals(prime(29), True)
- test.assert_equals(prime(12345),False)
- test.assert_equals(prime(36),False)
- test.assert_equals(prime(36),False)
- test.assert_equals(prime(0), False)
- test.assert_equals(prime(1), False)
- test.assert_equals(prime(2), True)
- test.assert_equals(prime(7), True)
- test.assert_equals(prime(13), True)
- test.assert_equals(prime(97), True)
- test.assert_equals(prime(29), True)