def listPrimes(nmax): # return a list of all primes < nmax by a fairly dumb algorithm primes = [2] for n in range(3, nmax): isPrime = True for p in primes: if n%p == 0: isPrime = False break if isPrime: primes.append(n) return primes