Program for nth Catalan Number | Function to print the number ; For the first number C ( 0 ) ; Iterate till N ; Calculate the number and print it ; Driver code ; Function call
function catalan ( n ) { let cat_ = 1 ; document . write ( cat_ + " " ) ; for ( let i = 1 ; i < n ; i ++ ) { cat_ *= ( 4 * i - 2 ) ; cat_ /= ( i + 1 ) ; document . write ( cat_ + " " ) ; } } let n = 5 ; catalan ( n ) ;