how to find previous fibonacci number in python

Solutions on MaxInterview for how to find previous fibonacci number in python by the best coders in the world

showing results for - "how to find previous fibonacci number in python"
Jeremy
19 May 2017
1# Python3 implementation of the approach
2from math import *
3 
4# Function to return the previous
5# fibonacci number
6def previousFibonacci(n):
7    a = n/((1 + sqrt(5))/2.0)
8    return round(a)
9 
10# Driver code
11n = 8
12print(previousFibonacci(n))
13
similar questions