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 :: stripping whitespace in python 
Python :: read excel by row and output to txt 
Python :: python button graphics.py 
Python :: one function in numpy array 
Python :: handlebars python 
Python :: python clear memory 
Python :: python dataframe add row 
Python :: binary tree deletion 
Python :: to_datetime with non zero padded values python 
Python :: python using os module file name from file path 
Python :: covert docx to pdf with libraoffice in python 
Python :: unique list 
Python :: python sweep two numbers 
Python :: pandas unstring list 
Python :: python sort list by rule 
Python :: class variable in python 
Python :: how can I print all items in a tuple, separated by commas? 
Python :: merge two dict python 
Python :: 0x80370102 kali linux 
Python :: getting last n rows of column 
Python :: @methodclass in python 
Python :: python sound 
Python :: pandas drop 1970 
Python :: cross_val_score scoring parameters types 
Python :: how to query DNS records using python 
Python :: python remove first element of list 
Python :: datetime to timestamp 
Python :: Pivot Spark data frame using python 
Python :: create table numpy 
Python :: onehotencoder = OneHotEncoder(categorical_features = [1]) X = onehotencoder.fit_transform(X).toarray() X = X[:, 1:] 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =