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
import java . util . * ; class GFG { static void catalan ( int n ) { int cat_ = 1 ; System . out . print ( cat_ + " ▁ " ) ; for ( int i = 1 ; i < n ; i ++ ) { cat_ *= ( 4 * i - 2 ) ; cat_ /= ( i + 1 ) ; System . out . print ( cat_ + " ▁ " ) ; } } public static void main ( String args [ ] ) { int n = 5 ; catalan ( n ) ; } }