Print Fibonacci Series in reverse order | JavaScript program to print Fibonacci series in reverse order ; Assigning first and second elements ; Storing sum in the preceding location ; Printing array in reverse order ; Driver Code
function reverseFibonacci ( n ) { let a = [ ] ; a [ 0 ] = 0 ; a [ 1 ] = 1 ; for ( let i = 2 ; i < n ; i ++ ) { a [ i ] = a [ i - 2 ] + a [ i - 1 ] ; } for ( let i = n - 1 ; i >= 0 ; i -- ) { document . write ( a [ i ] + " " ) ; } } let n = 5 ; reverseFibonacci ( n ) ;