Jun-05-2019, 10:06 AM
You can improve the algorithm, if you define some primes.
Here an example:
Here an example:
def is_prime(n): primes = [ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 ] if n == 2: return True elif n % 2 == 0 or n <= 1: return False # speed up with known primes if n > 50 and any(n % p == 0 for p in primes): return False sqr = int(math.sqrt(n)) + 1 for divisor in range(3, sqr, 2): if n % divisor == 0: return False return True
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!