Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hvnsweeting committed Nov 25, 2012
1 parent 698ab0c commit 2035353
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Python/fib_yield.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# A python yeild example to generate fibonacci number

def fib():
def fib(n):
cntr = 0
a, b = 0, 1
while 1:
yield b
while cntr < n:
yield a
a, b = b, a + b

cntr = 0
for n in fib():
print n
cntr += 1
if cntr == 10:
break
cntr += 1

for i in fib(10):
print i

0 comments on commit 2035353

Please sign in to comment.