Advertisement
Guest User

wxPython Fibonacci function

a guest
May 10th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. class FibonacciModel(ModelInterface):
  2.     def Generate(self):
  3.         cval = self.GetValue()
  4.         # Get the next one
  5.         for fib in self.fibonacci():
  6.             if fib > cval:
  7.                 self.SetValue(fib)
  8.                 break
  9.  
  10.     #@staticmethod
  11.     #def fibonacci():
  12.     def fibonacci(self):
  13.         """Fibonacci generator method"""
  14.         a, b = 0, 1
  15.         while 1:
  16.             yield a
  17.             a, b = b, a + b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement