To return to the original question for a moment, there's no need to have a loop. Why would you possibly want to use a loop to generate a second random number when you can do it on the first try?
Say the first roll is 6. The second roll must be one of the set {1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13}. There's 12 digits there. Thus, we can "roll a 12-sided die" and use that value. However, if the value on this roll is a 6, we return 13.
code: |
var n := 13
var d1 := Rand.Int (1, n)
var d2 := Rand.Int (1, n - 1)
if d2 = d1 then
d2 := n
end if
|