# Solved: fibonacci series recursive python

The main problem with recursive Fibonacci series is that it can become very difficult to track the sequence of Fibonacci numbers as the series progresses. This can become a problem if you need to reference a particular number in the series, or if you need to perform some sort of calculation on the series as it progresses.

def Fibonacci(n):
if n<0: print("Incorrect input") elif n==1: return 0 elif n==2: return 1 else: return Fibonacci(n-1)+Fibonacci(n-2)[/code] This is a recursive function for generating Fibonacci numbers. It takes an input of n, and if n is less than 0, it prints "Incorrect input". If n is equal to 1, it returns 0. If n is equal to 2, it returns 1. Otherwise, it returns the Fibonacci number of n-1 plus the Fibonacci number of n-2.

## What is Fibonacci serie

The Fibonacci series is a sequence of numbers in which each number is the sum of the previous two. The first number in the Fibonacci series is 0, and the second number is 1. The next number in the Fibonacci series is 1 + 1 = 2, and so on.

## Recursive

In Python, recursion is a way of solving problems by calling a function or method repeatedly. Recursion can be used to solve problems such as finding the maximum or minimum value of a list, counting the number of occurrences of a certain word in a text file, or calculating the Fibonacci sequence.

To use recursion in Python, you first need to create a function that will be called recursively. The following code example shows how to create a function that calculates the sum of two lists:

def sum_of_lists(first_list, second_list): return first_list + sum_of_lists(second_list, len(second_list))

Next, you need to call the function from within another function. The following code example shows how to calculate the Fibonacci sequence using recursion:

def Fibonacci(n): if n<0: print("Incorrect input") else: return Fibonacci(n-1)+Fibonacci(n-2)

Related posts: