Print first N terms of Lower Wythoff sequence | Function to print the first n terms of the lower Wythoff sequence ; Calculate value of phi ; Find the numbers ; a ( n ) = floor ( n * phi ) ; Print the nth numbers ; Driver code
function lowerWythoff ( n ) { var phi = ( 1 + Math . sqrt ( 5 ) ) / 2.0 ; for ( var i = 1 ; i <= n ; i ++ ) { var ans = Math . floor ( i * phi ) ; document . write ( ans ) ; if ( i != n ) document . write ( " " ) ; } } var n = 5 ; lowerWythoff ( n ) ;