# Python program to find Fibonacci series up to n

## Find Fibonacci series up to n

In this Python Program, We will be finding n number of elemenets of a Fibonacci series. Fibonacci Series are those numbers which are started from 0, 1 and their next number is the sum of the previous two numbers. So, First few fibonacci series elements are 0,1,1,2,3,5,8,13 and so on. This program will ask one user input and then it will print that n number of elements of fibonacci series.
For Example:
Limit is Fibonacci series : 10
Sequence is 0,1,1,2,3,5,8,13,21, 34 ### Working:

Step 1. Start

Step 2. Take a user input and store into int type num variable.

Step 3. Initialize n1, n2 variable to 0, 1.

Step 4. Run a for loop starts from 2 to num value.

Step 5. Inside for loop, using arithmetic addition method, and calculate the n3, where n3 = n1 + n2. Then initialize n1 = n2 and n2 = n3.

Step 6. Print n3 inside the loop.

Stop 7. Stop

### Python Program:

```# Method 1

def fibonacciSeries(i):
if i <= 1:
return i
else:
return (fibonacciSeries(i - 1) + fibonacciSeries(i - 2))

if num <= 0:
else:
print("Fibonacci Series:", end=" ")
for i in range(num):
print(fibonacciSeries(i), end=" ")

# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
```
```# Method 2

num = int(input("Enter the Number:"))
n1, n2 = 0, 1
print("Fibonacci Series:", n1, n2, end=",")
for i in range(2, num):
n3 = n1 + n2
n1 = n2
n2 = n3
print(n3, end=" ")

print()

# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
```

### Output:

Enter the Number: 8

Fibonacci Series: 0 1 1 2 3 5 8 13

### One comment on “Python program to find Fibonacci series up to n”

• Sunil

n=int(input(“Enter how many number you want in the series: “))
First=0
Second=1
for i in range(n):
print(First)
temp=First
First=Second
Second=temp+Second 10