
February 11th, 2013, 10:15 AM
|
 |
Contributing User
|
|
|
|
n didn't change.
Insert a print statement (and be prepared to interrupt):
Code:
>>> def nextPrime(primeList):
... checkNum = 3
... while True:
... for i in primeList:
... if checkNum % i == 0:
... break
... if i > math.sqrt(checkNum):
... yield checkNum
... break
... checkNum += 2
...
>>>
>>> def primeNumbers(limit):
... primeList = [2]
... n = next(nextPrime(primeList))
... while n <= limit:
... primeList.append(n)
... print(primeList) ###################### here
... return primeList
...
>>> import math
>>> primeNumbers(8)
[2, 3]
[2, 3, 3]
[2, 3, 3, 3]
[2, 3, 3, 3, 3]
[2, 3, 3, 3, 3, 3]
^C
__________________
[code] Code tags[/code] are essential for python code!
|