Tabular method
For two dice, the simplest way to do it is to do a 2-dimensional grid, then count the number of results.
A 1 2 3 4 Chances
B ----------- Of 24
1 | 1 2 3 4 | 1
2 | 2 2 3 4 | 3
3 | 3 3 3 4 | 5
4 | 4 4 4 4 | 7
5 | 5 5 5 5 | 4
6 | 6 6 6 6 | 4
One can unwrap such a table into a second table...
AB 1 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6 Chances
C -------------------------------------------------- of 4*5*6
1 | 1 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6 | 1 (1-0)
2 | 2 2 2 2 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6 | 7 (8-1)
3 | 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6 | 19 (27-16)
4 | 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 6 6 6 6 | 37 (64-27)
5 | 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 | 36 4*(25-16)
6 | 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 | 44 4*(36-25)
7 | 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 | 24
8 | 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 | 24
---------------------------------------------------
Formulaic method
Given A ≤ B, and any N ≤ A, odds of N on higher of 1dA and 1dB are (N^2)-((N-1)^2)/(A*B), and any A
For 3d, where N ≤ A ≤ B ≤ C, odds of N are ((N^3)-((N-1)^3))/(A*B*C).
IIRC, Where A < N ≤ B ≤ C, odds of N are A*((N^2)-((N-1)^2))/(A*B*C).
IIRC, where A ≤ B < N ≤ C, odds of N are A*B/(A*B*C)
For 4d, it should be...
N ≤ A ≤ B ≤ C ≤ D, chance(N)= ((N^4)-(N^3))/(A*B*C*D)
A ≤ N ≤ B ≤ C ≤ D, chance(N)= A*((N^3)-(N^2))/(A*B*C*D)
A ≤ B ≤ N ≤ C ≤ D, chance(N)= A*B*((N^2)-(N^1))/(A*B*C*D)
A ≤ B ≤ C ≤ N ≤ D, chance(N)= A*B*C/(A*B*C*D)
And so on...
Programmatic method
It's possible to use nested for/next loops. I'll provide a python example, because it's cheap, easy, and has nifty tools like .sort()...
T = 0
R = [0,0,0,0,0,0,0,0,0,0,0]
' R needs one more "0," than the largest number of sides
' we set up a for line for each die, with the possible results in the entries.
For A in [1,2,3,4]:
for B in [1,2,3,4,5,6]:
for C in [1,2,3,4,5,6,7,8]:
for D in [1,2,3,4,5,6,7,8,9,10]:
' now we do actual work...
temp = [0,0,0,0]
' reset temp
temp[0]=A
temp[1]=B
temp[2]=C
temp[3]=D
' we've just loaded the current die's values into array Temp
temp.sort()
' we've just put them into order
n = temp[3]
' we get the high die
R[n] += 1
' we increment the count for a result of n
T += 1
' we count the total iterations.
X = 0
' we're setting our output loop next, and it uses X as a counter
for Y in R:
print X, Y
' print current entry labeled.
X += 1
' increment X
Similar methods can be used in many languages, but for this kind of calculation I use Python for its really robust arrays.