Find the previous fibonacci number | Java implementation of the approach ; Function to return the previous fibonacci number ; Driver code
import java . io . * ; class GFG { static int previousFibonacci ( int n ) { double a = n / ( ( 1 + Math . sqrt ( 5 ) ) / 2.0 ) ; return ( int ) Math . round ( a ) ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( previousFibonacci ( n ) ) ; } }