Motzkin number | Return the nth Motzkin Number . ; Base Case ; Recursive step ; driver code
function motzkin ( n ) { if ( n == 0 n == 1 ) return 1 ; return ( ( 2 * n + 1 ) * motzkin ( n - 1 ) + ( 3 * n - 3 ) * motzkin ( n - 2 ) ) / ( n + 2 ) ; } var n = 8 ; document . write ( motzkin ( n ) ) ;