Create a table to store results of subproblems . row and column are used for simpilicity ( Number of dice is directly used as row index and sum is directly used as column index ) . The entries in 0 th row and 0 th column are never used .
int [ , ] table = new int [ n + 1 , x + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) for ( int j = 0 ; j <= x ; j ++ ) table [ i , j ] = 0 ;