SchrÃ ¶ derâ €“ Hipparchus number | A memoization based optimized Javascript program to find n - th Schroder - Hipparchus number ; Driver code
let MAX = 500 ; function nthSHN ( n , dp ) { if ( n == 1 n == 2 ) return dp [ n ] = 1 ; if ( dp [ n ] != - 1 ) return dp [ n ] ; return dp [ n ] = ( ( 6 * n - 9 ) * nthSHN ( n - 1 , dp ) - ( n - 3 ) * nthSHN ( n - 2 , dp ) ) / n ; } let n = 6 ; let dp = new Array ( MAX ) ; for ( let i = 0 ; i < dp . length ; i ++ ) dp [ i ] = - 1 ; document . write ( nthSHN ( n , dp ) ) ;