Advertisement
eeperry

Lucas Numbers Generator

Feb 7th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. # Lucas Numbers generator
  2. # Will produce n Lucas numbers
  3. def lucas(n):
  4.     table = []
  5.     for i in range(0, n):
  6.         if i == 0:
  7.             value = 2
  8.         elif i == 1:
  9.             value = 1
  10.         else:
  11.             value = table[i-1] + table[i-2]
  12.         table.append(value)
  13.         yield value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement