Argh I have a bachelor's degree in that (which I don't use and I have pretty much forgotten) but the basic way to do it is to count the number of possible combinations of dice that amount to 31 and divide by the total number of possible combinations (in case of 10d6, it's 6^10, which is 60,466,176.
For your second formula, you'd need to add, for example, the probabilities of getting 31, 32, 33, 34, 35 and 36, calculating each indenpendently before.
Now, a simpler, less accurate way to do it would be to simulate, say, 1,000 or 10,000 rolls in a excel sheet and estimate the probability from there.
I'll whip something up and attach it.
AR
EDIT: What's in the file:
Prob Estimator sheet: Enter a number of dice to roll (1-20), a maximum for each die (1-100) and a modifier to each die (1-20). Below appears the range of sums possible, and the calculated occurances of each sums. For example, if you wish to roll 10d6+0, you enter 10; 6 and 0, and below will appear a table with the possible sums of 10 to 60, with the number of occurances found in the "Rolls and Sums" sheet, the % of occurances for each sum, and the % of occurances of each sum high or equal to the sum in the corresponding line.
Rolls & Sums sheet: 1000 random rolls of the die of your choice. I went with 1000 because at 10000, the sheet kind of bogged down. At 1000, it's still pretty fast.
Note: If you want to print the table out, make sure to set the print area accordingly, since there are 2000 lines in that sheet (most of them empty) and you don't want to be printing out a great number of blank pages.
Note 2: I didn't calculate the real probability, but a number of occurances in 1000 random rolls. The results will vary from computation to computation even if the variables stay the same. It should nevertheless give you a good idea of the probability (within a few %'s, I'd say).
Hope someone finds this useful!
AR