mirror of
https://github.com/correl/euler.git
synced 2024-11-24 03:00:08 +00:00
Correl Roush
715e24dcf3
excecutable code if they are called directly. git-svn-id: file:///srv/svn/euler@29 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
17 lines
404 B
Python
17 lines
404 B
Python
def primes(limit):
|
|
primes = [2]
|
|
i = 3
|
|
while len(primes) < limit:
|
|
is_prime = True
|
|
for p in primes:
|
|
if i % p == 0:
|
|
is_prime = False
|
|
break
|
|
if is_prime:
|
|
primes.append(i)
|
|
i = i + 2
|
|
return primes
|
|
|
|
if __name__ == '__main__':
|
|
print '6th Prime', primes(6)[-1]
|
|
print '10001st Prime', primes(10001)[-1]
|