# Develop Program to Print Fibonacci Sequence in python

January 27 2020

First, we have to understand what is the Fibonacci sequence, which forms a sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.

For example the number sequence, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...

Simply write the program in two different ways,

# Define the variable for first two terms, 'a' and 'b',

a, b = 0, 1

count = 0

number_terms = int(input("How Many Terms?: "))

print ("Fibonacci sequence values are,\n")

while ( count < number_terms ):

print( a, end=',' )

c = ( a + b)

a = b

b = c

count += 1

print("\n")

If you want to set the until the maximum numbers,

# Define the variable for first two terms, 'a' and 'b',

a, b = 0, 1

count = 0

number_terms = int(input("How Many Terms?: "))

print ("Fibonacci sequence values are,\n")

while ( a < number_terms ):

print( a, end=',' )

c = ( a + b)

a = b

b = c

count += 1

print("\n")

## Comments (0)