Compute the probabilies for all values from 2 to N
for ( let i = 2 ; i <= n ; i ++ ) for ( let j = i - 1 ; j <= 6 * ( i - 1 ) ; j ++ ) for ( let k = 1 ; k <= 6 ; k ++ ) { dp [ i ] [ j + k ] += ( dp [ i - 1 ] [ j ] * dp [ 1 ] [ k ] ) ; }