#!/usr/bin/python def getPrimesTill(max): primes = [2] for i in xrange(3, max, 2): for p in primes: if i % p == 0 or p * p > i: break if i % p != 0: primes.append(i) primes.insert(0, 1) return primes print getPrimesTill(1000000) # End