Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

most efficient fibonacci number algorithm

>>> def fib_to(n):
...     fibs = [0, 1]
...     for i in range(2, n+1):
...         fibs.append(fibs[-1] + fibs[-2])
...     return fibs
...
Comment

most efficient fibonacci number algorithm

>>> def fib(n, computed = {0: 0, 1: 1}):
...     if n not in computed:
...         computed[n] = fib(n-1, computed) + fib(n-2, computed)
...     return computed[n]
Comment

PREVIOUS NEXT
Code Example
Python :: comprehensive python cheat sheet 
Python :: python get unicode spaces 
Python :: python assertRaises with class property 
Python :: aes in django 
Python :: qaction disacble python 
Python :: como escribir letras griegas en python 
Python :: how to create decorator function in django 
Python :: simple example of printing a C version of a SymPy expression: 
Python :: list exaple in python 
Python :: next function with inherited list python 
Python :: python to pseudo code converter 
Python :: .all() python numpy 
Python :: python code to open an application 
Python :: unique items in a list python 
Python :: unban member using ID discord.py 
Python :: python string index 
Python :: pandas add time to datetime 
Python :: python / vs // 
Python :: whatsapp bot python code 
Python :: how to use pyplot 
Python :: pytesseract.image_to 
Python :: round down number python 
Python :: how to create multiple variables in a loop python 
Python :: false python 
Python :: convert int to hexadecimal 
Python :: numpy indexing 
Python :: matplotlib subplots share x axis 
Python :: self.variable 
Python :: reading an image using opencv library 
Python :: python xgboost 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =