from math import sqrt def primemaker(x): primes = [] if x < 2: return [] else: primes.append(2) for possible_prime in range(3,(x+1), 2): #only odd numbers limit = sqrt(possible_prime) for prime in primes: if prime > limit: primes.append(possible_prime) break if not possible_prime % prime: break return primes
- from math import sqrt
- def primemaker(x):
- primes = []
- if x < 2:
- return []
- else:
- primes.append(2)
- for possible_prime in range(3,(x+1), 2): #only odd numbers
- limit = sqrt(possible_prime)
- for prime in primes:
- if prime > limit:
- primes.append(possible_prime)
- break
if 0 == possible_prime % prime:- if not possible_prime % prime:
- break
- return primes