Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Fibonacci series up to n python

>>> def fib2(n):  # return Fibonacci series up to n
...     """Return a list containing the Fibonacci series up to n."""
...     result = []
...     a, b = 0, 1
...     while a < n:
...         result.append(a)    # see below
...         a, b = b, a+b
...     return result
...
>>> f100 = fib2(100)    # call it
>>> f100                # write the result
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
Comment

python Fibonacci series up to n

def fib(n):
    a, b = 0, 1
    while a < n:
        print(a, end=' ')
        a, b = b, a+b
    print()


fib(1000)
Comment

PREVIOUS NEXT
Code Example
Python :: when to register app in django 
Python :: is boolean number python 
Python :: palindrome program in python 
Python :: Joining String And Variable 
Python :: Draw GFG Geeks For Geeks Logo using Python and Turtle 
Python :: gensim loop through models 
Python :: panda3d intervals 
Python :: python csv file plot column 
Python :: while except python 
Python :: python pod status phase 
Python :: flask docker redirect container name 
Python :: list of bad words python 
Python :: welcoming users using discord.py 
Python :: list comperhension condition in python 
Python :: stackoverflow Django ForeignKey 
Python :: python getting line length using list comprehension 
Python :: if else ifadesi 
Python :: hash tables in python 
Python :: nums: List[int] in python function 
Python :: machine earning to predict sentimentanalysis python 
Python :: datetime day deutsch python 
Python :: make a copy for parsing dataframe python 
Python :: matlab index last element 
Python :: gcp jupyter use python variables in magic bigquery 
Python :: jupyter notebook file not opening about::blank 
Python :: Improve the Request Add Headers to Requests 
Python :: how to save a count countvectorizer model in python 
Python :: how to look up players states in skyblock hypixel python 
Python :: lol infinite print in python 
Python :: rom requests_html import HTML 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =