Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Find Fibbonaci series using For Loop


This examples shows, how to find fibonacci series. Fibonacci series is a sequence of numbers where each number is the sum of the previous two consecutive numbers. The series begins with 0 and 1.

Steps
  1. Get the input number from user.
  2. Fibonacci series sequence of numbers in which each number is the sum of the two preceding ones.
  3. Fibonacci series starting with 0 and 1.
Example :
Example.py
val = int(input("Enter a number: ")) 
a = 0
b = 1
print("Fibonacci Series:", a, b, end=" ")
for i in range(2, val):
    c = a + b
    a = b
    b = c
    print(c, end=" ")

Output

Enter a number: 8
Fibonacci Series: 0 1 1 2 3 5 8 13

Prev Next