SchrÃ ¶ derâ €“ Hipparchus number | A memoization based optimized Java program to find n - th Schroder - Hipparchus number ; Driver code
import java . util . Arrays ; class GFG { static final int MAX = 500 ; static int nthSHN ( int n , int 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 ; } public static void main ( String [ ] args ) { int n = 6 ; int dp [ ] = new int [ MAX ] ; Arrays . fill ( dp , - 1 ) ; System . out . println ( nthSHN ( n , dp ) ) ; } }