diff --git a/Algorithms.py b/Algorithms.py index c8bd384..00a8733 100644 --- a/Algorithms.py +++ b/Algorithms.py @@ -31,17 +31,17 @@ def primeGenerator(): #Return 2 the first time, this lets us skip all even numbers later yield 2 - #Map composite integers to primes witnessing their compositeness + #Dictionary to hold the primes we have already found dict = {} #Start checking for primes with the number 3 and skip all even numbers for possiblePrime in itertools.count(3, 2): - #If q is not in the dictionary it is a new prime number - #Return it and mark it's next multiple + #If possiblePrime is not in the dictionary it is a new prime number + #Return it and mark its next multiple if possiblePrime not in dict: yield possiblePrime dict[possiblePrime * possiblePrime] = [possiblePrime] - #If q is in the dictionary it is a composite number + #If possiblePrime is in the dictionary it is a composite number else: #Move each witness to it's next multiple for num in dict[possiblePrime]: