mirror of
https://bitbucket.org/Mattrixwv/pyclasses.git
synced 2025-12-06 18:33:58 -05:00
Updated fibGenerator
This commit is contained in:
@@ -52,12 +52,13 @@ def primeGenerator():
|
|||||||
#Skip all multiples of 2
|
#Skip all multiples of 2
|
||||||
possiblePrime += 2
|
possiblePrime += 2
|
||||||
|
|
||||||
|
#Generate an inifinite sequence of fibonacci numbers
|
||||||
def fibGenerator():
|
def fibGenerator():
|
||||||
#The first and second fibonacci numbers are 1 and 1
|
#Set this so the first returned number is 1 and the second is also 1
|
||||||
a, b = 1, 1
|
a, b = 0, 1
|
||||||
|
|
||||||
while(True):
|
while(True):
|
||||||
yield a
|
yield b
|
||||||
a, b = b, a + b
|
a, b = b, a + b
|
||||||
|
|
||||||
#This function returns a list with all the prime numbers <= goalNumber
|
#This function returns a list with all the prime numbers <= goalNumber
|
||||||
|
|||||||
Reference in New Issue
Block a user