Count ways to divide circle using N non | JavaScript 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 function
function chordCnt ( A ) { var n = 2 * A ; var dpArray = Array ( n + 1 ) . fill ( 0 ) ; dpArray [ 0 ] = 1 ; dpArray [ 2 ] = 1 ; for ( var i = 4 ; i <= n ; i += 2 ) { for ( var j = 0 ; j < i - 1 ; j += 2 ) { dpArray [ i ] += ( dpArray [ j ] * dpArray [ i - 2 - j ] ) ; } } return dpArray [ n ] ; } var N ; N = 2 ; document . write ( chordCnt ( N ) + ' ' ) ; N = 1 ; document . write ( chordCnt ( N ) + ' ' ) ; N = 4 ; document . write ( chordCnt ( N ) + ' ' ) ;