Sum of Fibonacci Numbers | Set 2 | Function to find the sum of first N + 1 fibonacci numbers ; Apply the formula ; Prvar the result ; Driver Code ; Function Call
function sumFib ( N ) { var num = ( ( 1 - Math . sqrt ( 5 ) ) / 2 ) ; var val = Math . round ( Math . abs ( 1 / ( Math . pow ( num , N + 2 ) + Math . pow ( num , N + 1 ) + Math . pow ( num , N ) + Math . pow ( num , N - 1 ) ) ) - 1 ) ; document . write ( val ) ; } var N = 3 ; sumFib ( N ) ;