def is_prime(n): return n == 2 or n > 1 and all(n % i for i in range(3, int(n**0.5)+1, 2))
- def is_prime(n):
return n > 1 and all(n % i for i in range(2, int(n**0.5)+1))- return n == 2 or n > 1 and all(n % i for i in range(3, int(n**0.5)+1, 2))
test.expect(is_prime(7) == True) test.expect(is_prime(17) == True) test.expect(is_prime(15) == False) test.expect(is_prime(21) == False) test.expect(is_prime(1729) == False) test.expect(is_prime(104729) == True) test.expect(is_prime(1299709) == True) test.expect(is_prime(1299721) == True) test.expect(is_prime(1299743) == True) test.expect(is_prime(1299763) == True) test.expect(is_prime(1299791) == True) test.expect(is_prime(1299811) == True) test.expect(is_prime(1299813) == False) test.expect(is_prime(1299817) == True) test.expect(is_prime(1299821) == True) test.expect(is_prime(1299827) == True) test.expect(is_prime(32416190071) == True) test.expect(is_prime(2**31-1) == True) test.expect(is_prime(2**40-87) == True) test.expect(is_prime(2**45-55) == True)
- test.expect(is_prime(7) == True)
- test.expect(is_prime(17) == True)
- test.expect(is_prime(15) == False)
- test.expect(is_prime(21) == False)
- test.expect(is_prime(1729) == False)
- test.expect(is_prime(104729) == True)
- test.expect(is_prime(1299709) == True)
- test.expect(is_prime(1299721) == True)
- test.expect(is_prime(1299743) == True)
- test.expect(is_prime(1299763) == True)
- test.expect(is_prime(1299791) == True)
- test.expect(is_prime(1299811) == True)
- test.expect(is_prime(1299813) == False)
- test.expect(is_prime(1299817) == True)
- test.expect(is_prime(1299821) == True)
- test.expect(is_prime(1299827) == True)
- test.expect(is_prime(32416190071) == True)
- test.expect(is_prime(2**31-1) == True)
- test.expect(is_prime(2**40-87) == True)
- test.expect(is_prime(2**45-55) == True)