Count ways to divide circle using N non | PHP code to count ways to divide circle using N non - intersecting chords . ; n = no of points required ; dp array containing the sum ; returning the required number ; Driver Code
< ? php function chordCnt ( $ A ) { $ n = 2 * $ A ; $ dpArray = array_fill ( 0 , $ n + 1 , 0 ) ; $ dpArray [ 0 ] = 1 ; $ dpArray [ 2 ] = 1 ; for ( $ i = 4 ; $ i <= $ n ; $ i += 2 ) { for ( $ j = 0 ; $ j < $ i - 1 ; $ j += 2 ) { $ dpArray [ $ i ] += ( $ dpArray [ $ j ] * $ dpArray [ $ i - 2 - $ j ] ) ; } } return $ dpArray [ $ n ] ; } $ N = 2 ; echo chordCnt ( $ N ) , " STRNEWLINE " ; $ N = 1 ; echo chordCnt ( $ N ) , " STRNEWLINE " ; $ N = 4 ; echo chordCnt ( $ N ) , " STRNEWLINE " ; ? >