Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python code to generate fibonacci series

# Function for nth Fibonacci number
 
def Fibonacci(n):
    if n<= 0:
        print("Incorrect input")
    # First Fibonacci number is 0
    elif n == 1:
        return 0
    # Second Fibonacci number is 1
    elif n == 2:
        return 1
    else:
        return Fibonacci(n-1)+Fibonacci(n-2)
 
# Driver Program
 
print(Fibonacci(10))
 
# This code is contributed by Saket Modi
Comment

how to code fibonacci series in python

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 :: show equation using geom_smooth 
Python :: shutdown flask server with request 
Python :: python string slicing 
Python :: select a random element from a list python 
Python :: making lists with loops in one line python 
Python :: lower upper in pytho 
Python :: dataframe standardise 
Python :: how to move tkinter images 
Python :: python remove repeated elements from list 
Python :: detect operating system using python 
Python :: how to convert a set to a list in python 
Python :: django include all columns admin show 
Python :: python matplt 
Python :: pandas dataframe lists as columns 
Python :: flask heroku 
Python :: python round down 
Python :: tensorflow bert implementation 
Python :: django id 
Python :: print typeof in python 
Python :: crear una clase en python 
Python :: how to take input for list in python 
Python :: copy list python 
Python :: numpy vector multiplication 
Python :: numpy find columns containing nan 
Python :: python set day of date to 1 
Python :: pandas dataframe froms string 
Python :: pandas dataframe get number of occurrence in column 
Python :: python call function from string 
Python :: remove tuple from list python 
Python :: how to make a resizable python tkinter window have a limit 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =