Here you go
def fib(maximum):
if maximum<2:
return []
current=[1,1]
while True:
candidate=sum(current[-2:])
if candidate>=maximum:
break
current.append(candidate)
return current
More Related Contents:
- How to know number is divisible by 3 or any odd number using bitwise operator in python [closed]
- Python run command till button is pressed
- What’s the difference between `raw_input()` and `input()` in Python 3?
- Spark Equivalent of IF Then ELSE
- Elegant ways to support equivalence (“equality”) in Python classes
- How to fix Python indentation
- Can you explain closures (as they relate to Python)?
- What does a . in an import statement in Python mean?
- Run a program from python, and have it continue to run after the script is killed
- Proper indentation for multiline strings?
- How do I implement __getattribute__ without an infinite recursion error?
- What exactly is Python’s iterator protocol?
- Tab completion in Python’s raw_input()
- How can I get all the request headers in Django?
- Using an index to get an item
- How to check if there exists a process with a given pid in Python?
- initialize a numpy array
- Surprising results with Python timeit: Counter() vs defaultdict() vs dict()
- How to read a config file using python
- String slugification in Python
- How to split a huge csv file based on content of first column?
- Running a Tkinter form in a separate thread
- Change main plot legend label text
- Sum of the integers from 1 to n
- Django custom annotation function
- How to express classes on the axis of a heatmap in Seaborn
- re.search() only matches the first occurrence
- Dump stacktraces of all active Threads
- run python script directly from command line
- How to click on Load More button within Google Trends and print all the titles through Selenium and Python