Python Program to Print Fibonacci Series Using While Loop
A Fibonacci Series is The Integer Sequence of 0, 1, 1, 2, 3,
5, 8….
The first two Number are 0 and 1.
All Other numbers are obtained by Adding the Preceding Two Number.
All Other numbers are obtained by Adding the Preceding Two Number.
Like 0+1 = 1 Series are = 0 , 1, 1
Then 1+ 1= 2
Series are = 0 , 1 , 1, 2
Then 1+ 2 = 3 Series are = 0, 1, 1,2,3
And So on…….
Example : Code Program
n1 , n2 = 0, 1
num = int(input("How Many Fibonacci Terms Required:"))
print(n1, end=" ")
print(n2, end=" ")
count = 2
while count < num:
next = n1 + n2
print(next, end=" ")
count += 1
n1 = n2
n2 = next
num = int(input("How Many Fibonacci Terms Required:"))
print(n1, end=" ")
print(n2, end=" ")
count = 2
while count < num:
next = n1 + n2
print(next, end=" ")
count += 1
n1 = n2
n2 = next
Output
Java Program Code
Java Program to Print Fibonacci Series
Post a Comment