mirror of
https://github.com/correl/euler.git
synced 2024-11-23 19:19:53 +00:00
Minor optimization to 007
git-svn-id: file:///srv/svn/euler@27 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
parent
6874be8b31
commit
743dbe3aef
1 changed files with 3 additions and 3 deletions
6
007.py
6
007.py
|
@ -1,6 +1,6 @@
|
||||||
def primes(limit):
|
def primes(limit):
|
||||||
primes = []
|
primes = [2]
|
||||||
i = 2
|
i = 3
|
||||||
while len(primes) < limit:
|
while len(primes) < limit:
|
||||||
is_prime = True
|
is_prime = True
|
||||||
for p in primes:
|
for p in primes:
|
||||||
|
@ -9,7 +9,7 @@ def primes(limit):
|
||||||
break
|
break
|
||||||
if is_prime:
|
if is_prime:
|
||||||
primes.append(i)
|
primes.append(i)
|
||||||
i = i + 1
|
i = i + 2
|
||||||
return primes
|
return primes
|
||||||
|
|
||||||
print '6th Prime', primes(6)[-1]
|
print '6th Prime', primes(6)[-1]
|
||||||
|
|
Loading…
Reference in a new issue