In the article, we will see how to implement Fobonacci series in python. This is important article for technical interview preparation.
What is Fibonacci series?
a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
How to calculate Fibonacci series
Given any number n , n is calculated as sum of n-1 and n-2
n = (n-1) + (n-2)
Fibonacci series start from 1
First 2 numbers are 1
For rest, above mentioned formula is used to calculate Fibonacci number.
Python implementation to get Fibonacci series
def getfibonacci(count): if(count<1): return "Invalid data" data=  j=0 while(j<count): if(j<2): data.append(1) else: data.append(data[j-1]+data[j-2]) j+=1 return data print(getfibonacci(100))
In the article, you have seen how to generate Fibonacci sequence in Python.
If in case you have doubt regarding implementation, please feel free to share us your concerns in discussion thread below, or mail us to firstname.lastname@example.org
This article is for technical interview preparation. Find more useful programming exercises in link below.
- How to check whether string is palindrome or not
- How to find prime numbers between a given range
- How to check whether number is Armstrong number
Xamnation is helping students in interview preparation and learning programming language. We are offering live classes, study material and interview preparation course. Please find below useful course.
- Aptitude preparation course for job interviews
- Puzzles course for job interviews
- Python course for job interviews
- Amazon job preparation course
- TCS job preparation course